[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scheme Mode and Regular Expression Literals

From: Stefan Monnier
Subject: Re: Scheme Mode and Regular Expression Literals
Date: Sat, 16 Mar 2024 22:02:10 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>    (setq-local
>     syntax-propertize-function
>     (lambda (beg end)
>       (goto-char beg)
>       (scheme-syntax-propertize-sexp-comment (point) end)
>       (funcall
>        (syntax-propertize-rules
>         ("\\(#\\);" (1 (prog1 "< cn"
>                          (scheme-syntax-propertize-sexp-comment
>                           (point) end))))
>         )
>        (point) end)
>       ;; For regular expression literals
>       (scheme-syntax-propertize-regexp-1 end)
>       (scheme-syntax-propertize-regexp-2 end)
>       ))))

Does this work for you?
The "funcall" in there is expected to scan through (point)...end and
move point accordingly, so once you call
`scheme-syntax-propertize-regexp-1` you're already "too far".

Instead you need to turn

       ("\\(#\\);" (1 (prog1 "< cn"
                         (point) end)))))

into something like:

       ("\\(#\\);" (1 (prog1 "< cn"
                         (point) end))))
       ("\\(#\\)/" (1 (prog1 "|"
                         (point) end))))

and then extend `scheme-syntax-propertize-sexp-comment` so it handles
the case when point is inside a regexp (based on `syntax-ppss`, just
like it currently does for the case where point is inside a sexp-comment).
[ And probably rename it while you're at it since it will not be only
  for "sexp comment" any more.  ]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]