unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Toshi Umehara <toshi@niceume.com>
Cc: Eli Zaretskii <eliz@gnu.org>,  jcubic@onet.pl,  emacs-devel@gnu.org
Subject: Re: Scheme Mode and Regular Expression Literals
Date: Sat, 16 Mar 2024 22:02:10 -0400	[thread overview]
Message-ID: <jwv1q89fwmx.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87zfuxln05.fsf@niceume.com> (Toshi Umehara's message of "Sun, 17 Mar 2024 09:28:58 +0900")

>    (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

      (syntax-propertize-rules
       ("\\(#\\);" (1 (prog1 "< cn"
                        (scheme-syntax-propertize-sexp-comment
                         (point) end)))))

into something like:

      (syntax-propertize-rules
       ("\\(#\\);" (1 (prog1 "< cn"
                        (scheme-syntax-propertize-sexp-comment
                         (point) end))))
       ("\\(#\\)/" (1 (prog1 "|"
                        (scheme-syntax-propertize-sexp-comment
                         (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.  ]


        Stefan




  reply	other threads:[~2024-03-17  2:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17  0:28 Scheme Mode and Regular Expression Literals Toshi Umehara
2024-03-17  2:02 ` Stefan Monnier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-03-19  3:06 Toshi Umehara
2024-03-19 13:36 ` Stefan Monnier
2024-03-23  2:45   ` Toshi Umehara
2024-03-09  2:59 Toshi Umehara
2024-03-09 13:37 ` Jakub T. Jankiewicz
2024-03-14  8:40 ` Eli Zaretskii
2024-03-14 11:38   ` Mattias Engdegård
2024-03-14 13:34     ` Stefan Monnier
2024-03-14 15:09       ` Jakub T. Jankiewicz
2024-02-27 14:46 Jakub T. Jankiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1q89fwmx.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jcubic@onet.pl \
    --cc=toshi@niceume.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).