emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Scheme-mode: Add support for regular expression literal


From: Stefan Monnier
Subject: Re: [PATCH] Scheme-mode: Add support for regular expression literal
Date: Sat, 23 Mar 2024 16:57:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> This patch against 'scheme.el' enables scheme-mode to handle regular
> expression literal #/regexp/ that is availabe in some Scheme
> implementations such as GNU Kawa [1] and Gauche [2].

Thanks, I was preparing to install the patch but then noticed that
I can't see your name in the list of people who signed the
copyright paperwork.
If indeed you haven't signed it yet, then we need you to sign that
paperwork first.  For that, please fill the form below and send it as
instructed to the FSF so they can send you the relevant paperwork
to sign.

In the mean time, some comments on your patch:

>     (syntax-propertize-rules
>      ("\\(#\\);" (1 (prog1 "< cn"
> -                     (scheme-syntax-propertize-sexp-comment (point) end)))))
> +                     (scheme-syntax-propertize-sexp-comment (point) end))))
> +    ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
> +                                        (syntax-ppss
> +                                         (match-beginning 0)))))
> +                     (put-text-property
> +                      (match-beginning 0)
> +                      (1+ (match-beginning 0))
> +                      'syntax-table (string-to-syntax "|"))
> +                     (scheme-syntax-propertize-regexp
> +                      (point) end)
> +                     nil)
> +                   )))
>     (point) end))

The \\( and \\) around the # are there to create a subgroup 1, but you
don't actually make use of this subgroup.  So either:

- Remove those \\( and \\) since they're not needed (and change the "(1"
  to "(0"), or

- Replace (match-beginning 0) and (1+ (match-beginning 0)) with
  (match-beginning 1) and (match-end 1).

> +(defun scheme-syntax-propertize-regexp (_ end)

If you don't make use of the first arg, better remove it form here and
from your callers.

> +  (let* ((state (syntax-ppss))
> +         (within-str (nth 3 state))
> +         (start-delim-pos (nth 8 state)))
> +    (when (and within-str
> +               (char-equal ?# (char-after start-delim-pos)))
> +      (while
> +          (and
> +           (re-search-forward "/" end t)
> +           (eq -1
> +               (% (save-excursion
> +                    (backward-char)
> +                    (skip-chars-backward "\\\\")) 2))))
> +      (when (< (point) end)

This condition will be true when `search-forward` failed to find
a slash before `end` (I suspect this is what causes the problems that
Mattias saw).  One way to fix the problem is to pass `move` rather than
`t` as last argument to `search-forward`.


        Stefan


Please email the following information to assign@gnu.org, and we will send you
the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject line of
the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
 Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own your changes?
 Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]


[Additional people we should notify about the progress of the assignment.]
Stefan Monnier <monnier@gnu.org>




reply via email to

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