From: Eli Zaretskii <eliz@gnu.org>
To: Toshi Umehara <toshi@niceume.com>,
Stefan Monnier <monnier@iro.umontreal.ca>
Cc: jcubic@onet.pl, emacs-devel@gnu.org
Subject: Re: Scheme Mode and Regular Expression Literals
Date: Thu, 14 Mar 2024 10:40:09 +0200 [thread overview]
Message-ID: <86edcdb40m.fsf@gnu.org> (raw)
In-Reply-To: <87sf105cw1.fsf@niceume.com> (message from Toshi Umehara on Sat, 09 Mar 2024 11:59:10 +0900)
> From: Toshi Umehara <toshi@niceume.com>
> Cc: emacs-devel@gnu.org
> Date: Sat, 09 Mar 2024 11:59:10 +0900
>
>
> Regular expression literals as exist in Gauche Scheme does not seem to
> work in scheme mode. #/regexp/ is not dealt as a chunk. I looked for its
> solution on the Web, and reached this web page,
> https://ardggy.hatenablog.jp/entry/2015/11/24/143713 (in Japanese). The
> solution on the page overwrites syntax-propertize-function and adds a
> new rule for regular expression literals. I got a hint from it, and have
> tried to manage backslash slash ( \/ ) not to finish the literal and
> backshashes of even numbers (like \\\\ ) not to work as escapes.
>
> Currently, the following code in init.el works for me.
>
> #+BEGIN_SRC
> (add-hook 'scheme-mode-hook
> (lambda ()
> (setq-local
> syntax-propertize-function
> (lambda (start end)
> (goto-char start)
> (funcall
> (syntax-propertize-rules
> ;; For #/regexp/ syntax
> ("\\(#\\)/\\(\\\\/\\|\\\\\\\\\\|.\\)*?\\(/\\)"
> (1 "|")
> (3 "|"))
> ;; For #; comment syntax
> ("\\(#\\);"
> (1 (prog1 "< cn"
> (scheme-syntax-propertize-sexp-comment
> (point) end)))))
> (point) end))
> ))
> )
> #+END_SRC
Thanks.
Stefan, is the below the right fix? I'm confused by the call to
scheme-syntax-propertize-sexp-comment that scheme-syntax-propertize
does at its very beginning -- what is it for?
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 67abab6..a83e5dc 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -412,6 +412,11 @@ scheme-syntax-propertize
(scheme-syntax-propertize-sexp-comment (point) end)
(funcall
(syntax-propertize-rules
+ ;; For #/regexp/ syntax
+ ("\\(#\\)/\\(\\\\/\\|\\\\\\\\\\|.\\)*?\\(/\\)"
+ (1 "|")
+ (3 "|"))
+ ;; For #; comment syntax
("\\(#\\);" (1 (prog1 "< cn"
(scheme-syntax-propertize-sexp-comment (point) end)))))
(point) end))
next prev parent reply other threads:[~2024-03-14 8:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-09 2:59 Scheme Mode and Regular Expression Literals Toshi Umehara
2024-03-09 13:37 ` Jakub T. Jankiewicz
2024-03-14 8:40 ` Eli Zaretskii [this message]
2024-03-14 11:38 ` Mattias Engdegård
2024-03-14 13:34 ` Stefan Monnier
2024-03-14 15:09 ` Jakub T. Jankiewicz
-- 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-17 0:28 Toshi Umehara
2024-03-17 2:02 ` Stefan Monnier
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=86edcdb40m.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=jcubic@onet.pl \
--cc=monnier@iro.umontreal.ca \
--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).