unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Toshi Umehara <toshi@niceume.com>
To: jcubic@onet.pl
Cc: emacs-devel@gnu.org
Subject: Re: Scheme Mode and Regular Expression Literals
Date: Sat, 09 Mar 2024 11:59:10 +0900	[thread overview]
Message-ID: <87sf105cw1.fsf@niceume.com> (raw)
In-Reply-To: 20240227154655.1f6057a0@jcubic


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

Hope this helps.

--
Toshi (Toshihiro Umehara)



             reply	other threads:[~2024-03-09  2:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09  2:59 Toshi Umehara [this message]
2024-03-09 13:37 ` Scheme Mode and Regular Expression Literals 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
  -- 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=87sf105cw1.fsf@niceume.com \
    --to=toshi@niceume.com \
    --cc=emacs-devel@gnu.org \
    --cc=jcubic@onet.pl \
    /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).