[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme Mode and Regular Expression Literals
From: |
Jakub T. Jankiewicz |
Subject: |
Re: Scheme Mode and Regular Expression Literals |
Date: |
Sat, 9 Mar 2024 14:37:12 +0100 |
This is perfect, thank you.
I also just noticed (while reading the docs) that GNU Kawa also have the same
syntax for regular expressions.
On Sat, 09 Mar 2024 11:59:10 +0900
Toshi Umehara <toshi@niceume.com> wrote:
> 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.
>
--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org