Skip to content

Commit

Permalink
Lisp: extract f in "(defsomething (setf f) ..."
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Nov 19, 2024
1 parent 4fdd94b commit b8fde38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Units/parser-lisp.r/more-defsomething.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ browser-schemes input.lisp /^(defgeneric browser-schemes (browser)$/;" kind:gene
%buffer input.lisp /^(defparameter %buffer nil)$/;" kind:parameter
:nyxt/renderer/gtk input.lisp /^(nyxt:define-package :nyxt\/renderer\/gtk$/;" kind:unknown
renderer-history-entry input.lisp /^(defstruct renderer-history-entry$/;" kind:struct
local-p input.lisp /^(defmethod (setf local-p) (value (scheme gtk-scheme))$/;" kind:method
6 changes: 6 additions & 0 deletions Units/parser-lisp.r/more-defsomething.d/input.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ content. In case something goes wrong, runs `error-callback'.")
original-url
gtk-object)


(defmethod (setf local-p) (value (scheme gtk-scheme))
(when value
(webkit:webkit-security-manager-register-uri-scheme-as-local (manager scheme)
(name scheme)))
(setf (slot-value scheme 'local-p) value))
17 changes: 17 additions & 0 deletions parsers/lisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ static int L_isquote (const unsigned char *strp, bool case_insensitive)
&& isspace (*(++strp)));
}

static int L_issetf (const unsigned char *strp, bool case_insensitive)
{
bool cis = case_insensitive; /* Renaming for making code short */

return ( (*(++strp) == 's' || (cis && *strp == 'S'))
&& (*(++strp) == 'e' || (cis && *strp == 'E'))
&& (*(++strp) == 't' || (cis && *strp == 'T'))
&& (*(++strp) == 'f' || (cis && *strp == 'F'))
&& isspace (*(++strp)));
}

static int lisp_hint2kind (const vString *const hint)
{
int k = K_UNKNOWN;
Expand Down Expand Up @@ -321,6 +332,12 @@ static void L_getit (vString *const name, const unsigned char *dbp,
while (isspace (*dbp))
dbp++;
}
else if (*dbp == '(' && L_issetf (dbp, case_insensitive)) /* Skip "(setf " */
{
dbp += 6;
while (isspace (*dbp))
dbp++;
}
for (p=dbp ; *p!='\0' && *p!='(' && !isspace (*p) && *p!=')' ; p++)
vStringPut (name, *p);

Expand Down

0 comments on commit b8fde38

Please sign in to comment.