* [PATCH] Scheme-mode: Add support for regular expression literal
@ 2024-03-23 2:40 Toshi Umehara
2024-03-23 14:28 ` Jakub T. Jankiewicz
2024-03-23 20:57 ` Stefan Monnier
0 siblings, 2 replies; 17+ messages in thread
From: Toshi Umehara @ 2024-03-23 2:40 UTC (permalink / raw)
To: emacs-devel; +Cc: monnier, Eli Zaretskii, jcubic
[-- Attachment #1: Type: text/plain, Size: 975 bytes --]
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].
Its need was posted by Jakub [3] and init configuration was first
proposed [4]. To allow multiline regular expression literal and to make
the code sophisticated, Stephan has given many advices [5-7]. These
advices are incorporated, and now the code works fine.
Thanks
Reference
[1] https://www.gnu.org/software/kawa/Regular-expressions.html
[2] https://practical-scheme.net/gauche/man/gauche-refe/Regular-expressions.html
[3] https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00896.html
[4] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00282.html
[5] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00397.html
[6] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00478.html
[7] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00538.html
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Enable dealing with scheme regular expression literal --]
[-- Type: text/x-patch, Size: 2979 bytes --]
From dc502360d9310408a8a72bafc2f8fa4fb120f30c Mon Sep 17 00:00:00 2001
From: niceume <toshi@niceume.com>
Date: Sun, 17 Mar 2024 09:12:32 +0900
Subject: [PATCH] Scheme-mode update for regular expression literal
---
etc/NEWS | 6 ++++++
lisp/progmodes/scheme.el | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index f4b4c30855c..d2c258bc6d8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1188,6 +1188,12 @@ instead of:
This allows the user to specify command line arguments to the non
interactive Python interpreter specified by 'python-interpreter'.
+** Scheme mode
+
+Scheme mode now handles regular expression literal #/regexp/ that is
+available in some Scheme implementations.
+
+
** use-package
+++
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 67abab6913d..d3fb40ea471 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -410,10 +410,22 @@ scheme-sexp-comment-syntax-table
(defun scheme-syntax-propertize (beg end)
(goto-char beg)
(scheme-syntax-propertize-sexp-comment (point) end)
+ (scheme-syntax-propertize-regexp (point) end)
(funcall
(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))
(defun scheme-syntax-propertize-sexp-comment (_ end)
@@ -430,6 +442,29 @@ scheme-syntax-propertize-sexp-comment
'syntax-table (string-to-syntax "> cn")))
(scan-error (goto-char end))))))
+
+(defun scheme-syntax-propertize-regexp (_ end)
+ (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)
+ (progn
+ (put-text-property
+ (match-beginning 0)
+ (match-end 0)
+ 'syntax-table (string-to-syntax "|"))
+ )))
+ ))
+
;;;###autoload
(define-derived-mode dsssl-mode scheme-mode "DSSSL"
"Major mode for editing DSSSL code.
--
2.44.0
[-- Attachment #3: Type: text/plain, Size: 31 bytes --]
--
Toshi (Toshihiro Umehara)
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-23 2:40 [PATCH] Scheme-mode: Add support for regular expression literal Toshi Umehara
@ 2024-03-23 14:28 ` Jakub T. Jankiewicz
2024-03-23 20:57 ` Stefan Monnier
1 sibling, 0 replies; 17+ messages in thread
From: Jakub T. Jankiewicz @ 2024-03-23 14:28 UTC (permalink / raw)
To: Toshi Umehara; +Cc: emacs-devel, monnier, Eli Zaretskii
Awesome, you did a great job. Didn't expected this to be include in scheme.el.
On Sat, 23 Mar 2024 11:40:47 +0900
Toshi Umehara <toshi@niceume.com> wrote:
> 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].
>
> Its need was posted by Jakub [3] and init configuration was first
> proposed [4]. To allow multiline regular expression literal and to make
> the code sophisticated, Stephan has given many advices [5-7]. These
> advices are incorporated, and now the code works fine.
>
> Thanks
>
> Reference
> [1] https://www.gnu.org/software/kawa/Regular-expressions.html
> [2]
> https://practical-scheme.net/gauche/man/gauche-refe/Regular-expressions.html
> [3] https://lists.gnu.org/archive/html/emacs-devel/2024-02/msg00896.html
> [4] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00282.html
> [5] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00397.html
> [6] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00478.html
> [7] https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00538.html
>
--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-23 2:40 [PATCH] Scheme-mode: Add support for regular expression literal Toshi Umehara
2024-03-23 14:28 ` Jakub T. Jankiewicz
@ 2024-03-23 20:57 ` Stefan Monnier
2024-03-24 4:33 ` Toshi Umehara
1 sibling, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2024-03-23 20:57 UTC (permalink / raw)
To: Toshi Umehara; +Cc: emacs-devel, Eli Zaretskii, jcubic
> 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>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-23 20:57 ` Stefan Monnier
@ 2024-03-24 4:33 ` Toshi Umehara
2024-03-28 11:33 ` Jakub T. Jankiewicz
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Toshi Umehara @ 2024-03-24 4:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Eli Zaretskii, jcubic
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
Thank you very much for reviewing the patch, Stefan.
The patch is updated.
- Subexpression 1 is now used for regular expression rule in
syntax-propertize-rules
- Unused arguments are removed from caller and callee of
scheme-syntax-propertize-regexp
- Changing the third argument of re-search-forward from t to 'move moves
the point to end if the search does not find closing slash, which is
ideal.
Attached patches are separated into three. The first one changes only
regular expression part mentioned above. The second one is NEWS update.
The third one removes unused arguments also for
scheme-syntax-propertize-sexp-comment . Please use them as you want.
Also about copyright assignment, this is the first commitment to GNU,
and I have filled out the form and have emailed it to assign@gnu.org .
Thanks
--
Toshi (Toshihiro Umehara)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Enable-dealing-with-regular-expression-literal.patch --]
[-- Type: text/x-patch; name="0001-Enable-dealing-with-regular-expression-literal.patch", Size: 2459 bytes --]
From a41f81da329bf9f753a901c02d05db14bcd0b651 Mon Sep 17 00:00:00 2001
From: niceume <toshi@niceume.com>
Date: Sun, 17 Mar 2024 09:12:32 +0900
Subject: [PATCH 1/3] Enable dealing with regular expression literal
---
lisp/progmodes/scheme.el | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 67abab6913d..fa272dd5c5c 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -410,10 +410,21 @@ scheme-sexp-comment-syntax-table
(defun scheme-syntax-propertize (beg end)
(goto-char beg)
(scheme-syntax-propertize-sexp-comment (point) end)
+ (scheme-syntax-propertize-regexp end)
(funcall
(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 1)
+ (match-end 1)
+ 'syntax-table (string-to-syntax "|"))
+ (scheme-syntax-propertize-regexp end)
+ nil)
+ )))
(point) end))
(defun scheme-syntax-propertize-sexp-comment (_ end)
@@ -430,6 +441,28 @@ scheme-syntax-propertize-sexp-comment
'syntax-table (string-to-syntax "> cn")))
(scan-error (goto-char end))))))
+(defun scheme-syntax-propertize-regexp (end)
+ (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 'move)
+ (eq -1
+ (% (save-excursion
+ (backward-char)
+ (skip-chars-backward "\\\\")) 2))))
+ (when (< (point) end)
+ (progn
+ (put-text-property
+ (match-beginning 0)
+ (match-end 0)
+ 'syntax-table (string-to-syntax "|"))
+ )))
+ ))
+
;;;###autoload
(define-derived-mode dsssl-mode scheme-mode "DSSSL"
"Major mode for editing DSSSL code.
--
2.44.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-NEWS-update-for-scheme-mode.patch --]
[-- Type: text/x-patch; name="0002-NEWS-update-for-scheme-mode.patch", Size: 691 bytes --]
From 4da80b5bd0993d4ceb20ada548cd459dd0e73b4f Mon Sep 17 00:00:00 2001
From: niceume <toshi@niceume.com>
Date: Sun, 24 Mar 2024 12:29:09 +0900
Subject: [PATCH 2/3] NEWS update for scheme-mode
---
etc/NEWS | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index f4b4c30855c..3d3b023f2bc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1188,6 +1188,11 @@ instead of:
This allows the user to specify command line arguments to the non
interactive Python interpreter specified by 'python-interpreter'.
+** Scheme mode
+
+Scheme mode now handles regular expression literal #/regexp/ that is
+available in some Scheme implementations.
+
** use-package
+++
--
2.44.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-remove-unused-arguments-from-scheme-syntax-propertiz.patch --]
[-- Type: text/x-patch; name="0003-remove-unused-arguments-from-scheme-syntax-propertiz.patch", Size: 1489 bytes --]
From 9f8ae3fb6c0f81824643180cbc9a53ca2acaa82a Mon Sep 17 00:00:00 2001
From: niceume <toshi@niceume.com>
Date: Sun, 24 Mar 2024 12:29:56 +0900
Subject: [PATCH 3/3] remove unused arguments from
scheme-syntax-propertize-sexp-comment
---
lisp/progmodes/scheme.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index fa272dd5c5c..fcaeafb4a75 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -409,12 +409,12 @@ scheme-sexp-comment-syntax-table
(defun scheme-syntax-propertize (beg end)
(goto-char beg)
- (scheme-syntax-propertize-sexp-comment (point) end)
+ (scheme-syntax-propertize-sexp-comment end)
(scheme-syntax-propertize-regexp end)
(funcall
(syntax-propertize-rules
("\\(#\\);" (1 (prog1 "< cn"
- (scheme-syntax-propertize-sexp-comment (point) end))))
+ (scheme-syntax-propertize-sexp-comment end))))
("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
(syntax-ppss
(match-beginning 0)))))
@@ -427,7 +427,7 @@ scheme-syntax-propertize
)))
(point) end))
-(defun scheme-syntax-propertize-sexp-comment (_ end)
+(defun scheme-syntax-propertize-sexp-comment (end)
(let ((state (syntax-ppss)))
(when (eq 2 (nth 7 state))
;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-24 4:33 ` Toshi Umehara
@ 2024-03-28 11:33 ` Jakub T. Jankiewicz
2024-03-28 12:40 ` Toshi Umehara
2024-04-01 6:17 ` Stefan Monnier
2024-03-30 7:59 ` Eli Zaretskii
2024-04-01 5:24 ` Stefan Monnier
2 siblings, 2 replies; 17+ messages in thread
From: Jakub T. Jankiewicz @ 2024-03-28 11:33 UTC (permalink / raw)
To: Toshi Umehara; +Cc: Stefan Monnier, emacs-devel, Eli Zaretskii
One note about original solution in .emacs file that I used. It doesn't
correctly handle #; it works only till the end of the line (it should comment
out whole S-Expression). I hope that the code that was proposed for the
scheme.el was tested and handle this correctly.
On Sun, 24 Mar 2024 13:33:19 +0900
"Toshi Umehara" <toshi@niceume.com> wrote:
> Thank you very much for reviewing the patch, Stefan.
>
> The patch is updated.
>
> - Subexpression 1 is now used for regular expression rule in
> syntax-propertize-rules
>
> - Unused arguments are removed from caller and callee of
> scheme-syntax-propertize-regexp
>
> - Changing the third argument of re-search-forward from t to 'move moves
> the point to end if the search does not find closing slash, which is
> ideal.
>
> Attached patches are separated into three. The first one changes only
> regular expression part mentioned above. The second one is NEWS update.
> The third one removes unused arguments also for
> scheme-syntax-propertize-sexp-comment . Please use them as you want.
>
> Also about copyright assignment, this is the first commitment to GNU,
> and I have filled out the form and have emailed it to assign@gnu.org .
>
> Thanks
>
--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-28 11:33 ` Jakub T. Jankiewicz
@ 2024-03-28 12:40 ` Toshi Umehara
2024-03-28 23:43 ` Jakub T. Jankiewicz
2024-04-01 6:17 ` Stefan Monnier
1 sibling, 1 reply; 17+ messages in thread
From: Toshi Umehara @ 2024-03-28 12:40 UTC (permalink / raw)
To: Jakub T. Jankiewicz; +Cc: Stefan Monnier, emacs-devel, Eli Zaretskii
The code below, which works in init.el, corresponds to the updated scheme.el .
Could you try it ?
(add-hook
'scheme-mode-hook
(lambda ()
(setq-local
syntax-propertize-function
(lambda (beg end)
(goto-char beg)
(scheme-syntax-propertize-sexp-comment2 end)
(scheme-syntax-propertize-regexp end)
(funcall
(syntax-propertize-rules
("\\(#\\);" (1 (prog1 "< cn"
(scheme-syntax-propertize-sexp-comment2 end))))
("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
(syntax-ppss
(match-beginning 0)))))
(put-text-property
(match-beginning 1)
(match-end 1)
'syntax-table (string-to-syntax "|"))
(scheme-syntax-propertize-regexp end)
nil)
)))
(point) end)))))
(defun scheme-syntax-propertize-sexp-comment2 (end)
(let ((state (syntax-ppss)))
(when (eq 2 (nth 7 state))
;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
(condition-case nil
(progn
(goto-char (+ 2 (nth 8 state)))
;; FIXME: this doesn't handle the case where the sexp
;; itself contains a #; comment.
(forward-sexp 1)
(put-text-property (1- (point)) (point)
'syntax-table (string-to-syntax "> cn")))
(scan-error (goto-char end))))))
(defun scheme-syntax-propertize-regexp (end)
(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 'move)
(eq -1
(% (save-excursion
(backward-char)
(skip-chars-backward "\\\\")) 2))))
(when (< (point) end)
(progn
(put-text-property
(match-beginning 0)
(match-end 0)
'syntax-table (string-to-syntax "|"))
)))
))
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-28 12:40 ` Toshi Umehara
@ 2024-03-28 23:43 ` Jakub T. Jankiewicz
2024-03-29 6:48 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Jakub T. Jankiewicz @ 2024-03-28 23:43 UTC (permalink / raw)
To: Toshi Umehara; +Cc: Stefan Monnier, emacs-devel, Eli Zaretskii
Yes, I can confirm it works. The comments works after a delay, it first
highlight single line immediately and after a second i highlight whole
expression.
On Thu, 28 Mar 2024 21:40:11 +0900
"Toshi Umehara" <toshi@niceume.com> wrote:
> The code below, which works in init.el, corresponds to the updated
> scheme.el . Could you try it ?
>
> (add-hook
> 'scheme-mode-hook
> (lambda ()
> (setq-local
> syntax-propertize-function
> (lambda (beg end)
> (goto-char beg)
> (scheme-syntax-propertize-sexp-comment2 end)
> (scheme-syntax-propertize-regexp end)
> (funcall
> (syntax-propertize-rules
> ("\\(#\\);" (1 (prog1 "< cn"
> (scheme-syntax-propertize-sexp-comment2 end))))
> ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
> (syntax-ppss
> (match-beginning 0)))))
> (put-text-property
> (match-beginning 1)
> (match-end 1)
> 'syntax-table (string-to-syntax "|"))
> (scheme-syntax-propertize-regexp end)
> nil)
> )))
> (point) end)))))
>
> (defun scheme-syntax-propertize-sexp-comment2 (end)
> (let ((state (syntax-ppss)))
> (when (eq 2 (nth 7 state))
> ;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
> (condition-case nil
> (progn
> (goto-char (+ 2 (nth 8 state)))
> ;; FIXME: this doesn't handle the case where the sexp
> ;; itself contains a #; comment.
> (forward-sexp 1)
> (put-text-property (1- (point)) (point)
> 'syntax-table (string-to-syntax "> cn")))
> (scan-error (goto-char end))))))
>
> (defun scheme-syntax-propertize-regexp (end)
> (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 'move)
> (eq -1
> (% (save-excursion
> (backward-char)
> (skip-chars-backward "\\\\")) 2))))
> (when (< (point) end)
> (progn
> (put-text-property
> (match-beginning 0)
> (match-end 0)
> 'syntax-table (string-to-syntax "|"))
> )))
> ))
>
--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-28 23:43 ` Jakub T. Jankiewicz
@ 2024-03-29 6:48 ` Eli Zaretskii
2024-03-29 11:09 ` Jakub T. Jankiewicz
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-03-29 6:48 UTC (permalink / raw)
To: Jakub T. Jankiewicz; +Cc: toshi, monnier, emacs-devel
> Date: Fri, 29 Mar 2024 00:43:23 +0100
> From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
> Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>, emacs-devel@gnu.org, "Eli
> Zaretskii" <eliz@gnu.org>
>
> Yes, I can confirm it works. The comments works after a delay, it first
> highlight single line immediately and after a second i highlight whole
> expression.
Is the delay related to jit-lock-antiblink-grace, per chance?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-29 6:48 ` Eli Zaretskii
@ 2024-03-29 11:09 ` Jakub T. Jankiewicz
2024-03-29 15:02 ` Toshi Umehara
0 siblings, 1 reply; 17+ messages in thread
From: Jakub T. Jankiewicz @ 2024-03-29 11:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: toshi, monnier, emacs-devel
On Fri, 29 Mar 2024 09:48:13 +0300
Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Fri, 29 Mar 2024 00:43:23 +0100
> > From: "Jakub T. Jankiewicz" <jcubic@onet.pl>
> > Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>, emacs-devel@gnu.org, "Eli
> > Zaretskii" <eliz@gnu.org>
> >
> > Yes, I can confirm it works. The comments works after a delay, it first
> > highlight single line immediately and after a second i highlight whole
> > expression.
>
> Is the delay related to jit-lock-antiblink-grace, per chance?
Sorry, I have no idea what is it and how the verify.
--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://lips.js.org
https://koduj.org
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-29 11:09 ` Jakub T. Jankiewicz
@ 2024-03-29 15:02 ` Toshi Umehara
2024-03-29 15:38 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: Toshi Umehara @ 2024-03-29 15:02 UTC (permalink / raw)
To: Jakub T. Jankiewicz, Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel
Hello Jakub, thank you for testing! I also did not know why there was a
delay.
As Eli mentions, I looked up for jit-lock-antiblink-grace, and found it
is defined as 'customizable' variable.
M-x customize
Input jit-lock-antiblink-grace and press Search
Change value from 2 to something like 0.1
Apply and Save
This save the new setting in init.el, and resolves the highlighting
delay. I feel this is an interesting feature because Emacs seems to
pretends to be slow, although it can get things done very fast :)
--
Toshi (Toshihiro Umehara)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-29 15:02 ` Toshi Umehara
@ 2024-03-29 15:38 ` Eli Zaretskii
2024-03-30 0:48 ` Toshi Umehara
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-03-29 15:38 UTC (permalink / raw)
To: Toshi Umehara; +Cc: jcubic, monnier, emacs-devel
> Date: Sat, 30 Mar 2024 00:02:51 +0900
> From: "Toshi Umehara" <toshi@niceume.com>
> Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
>
> Hello Jakub, thank you for testing! I also did not know why there was a
> delay.
>
> As Eli mentions, I looked up for jit-lock-antiblink-grace, and found it
> is defined as 'customizable' variable.
>
> M-x customize
> Input jit-lock-antiblink-grace and press Search
> Change value from 2 to something like 0.1
> Apply and Save
>
> This save the new setting in init.el, and resolves the highlighting
> delay. I feel this is an interesting feature because Emacs seems to
> pretends to be slow, although it can get things done very fast :)
That option exists because some users prefer an instant fontification,
whereas others prefer not to see the momentary "blinking" of wrong
fontification when you have typed "foo bar (with the leading quote),
but didn't yet type the closing quote -- this causes font-lock to
fontify the entire buffer from that place to EOB as a single string.
The 2 seconds of the default value give you 2 sec of grace to type the
closing quote.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-29 15:38 ` Eli Zaretskii
@ 2024-03-30 0:48 ` Toshi Umehara
0 siblings, 0 replies; 17+ messages in thread
From: Toshi Umehara @ 2024-03-30 0:48 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Jakub T. Jankiewicz, Stefan Monnier, emacs-devel
I like this feature. Thank you for clarification !
--
Toshi (Toshihiro Umehara)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-24 4:33 ` Toshi Umehara
2024-03-28 11:33 ` Jakub T. Jankiewicz
@ 2024-03-30 7:59 ` Eli Zaretskii
2024-04-01 5:31 ` Stefan Monnier
2024-04-01 5:24 ` Stefan Monnier
2 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2024-03-30 7:59 UTC (permalink / raw)
To: Toshi Umehara; +Cc: monnier, emacs-devel, jcubic
> Date: Sun, 24 Mar 2024 13:33:19 +0900
> From: "Toshi Umehara" <toshi@niceume.com>
> Cc: emacs-devel@gnu.org, "Eli Zaretskii" <eliz@gnu.org>, jcubic@onet.pl
>
> Thank you very much for reviewing the patch, Stefan.
>
> The patch is updated.
>
> - Subexpression 1 is now used for regular expression rule in
> syntax-propertize-rules
>
> - Unused arguments are removed from caller and callee of
> scheme-syntax-propertize-regexp
>
> - Changing the third argument of re-search-forward from t to 'move moves
> the point to end if the search does not find closing slash, which is
> ideal.
>
> Attached patches are separated into three. The first one changes only
> regular expression part mentioned above. The second one is NEWS update.
> The third one removes unused arguments also for
> scheme-syntax-propertize-sexp-comment . Please use them as you want.
Stefan, any further comments? Or should I install this?
My only comment is that removing the unused argument from
scheme-syntax-propertize-sexp-comment constitutes a change in a public
API, so maybe we should not do that.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-24 4:33 ` Toshi Umehara
2024-03-28 11:33 ` Jakub T. Jankiewicz
2024-03-30 7:59 ` Eli Zaretskii
@ 2024-04-01 5:24 ` Stefan Monnier
2024-04-02 8:48 ` Toshi Umehara
2 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2024-04-01 5:24 UTC (permalink / raw)
To: Toshi Umehara; +Cc: emacs-devel, Eli Zaretskii, jcubic
> The patch is updated.
Thank you. Pushed to `master` (with more complete commit messages).
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-30 7:59 ` Eli Zaretskii
@ 2024-04-01 5:31 ` Stefan Monnier
0 siblings, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2024-04-01 5:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Toshi Umehara, emacs-devel, jcubic
> Stefan, any further comments? Or should I install this?
I was waiting for the copyright paperwork to come through.
> My only comment is that removing the unused argument from
> scheme-syntax-propertize-sexp-comment constitutes a change in a public
> API, so maybe we should not do that.
While the name doesn't include a "--", it's really an internal function,
so I think it's OK.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-03-28 11:33 ` Jakub T. Jankiewicz
2024-03-28 12:40 ` Toshi Umehara
@ 2024-04-01 6:17 ` Stefan Monnier
1 sibling, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2024-04-01 6:17 UTC (permalink / raw)
To: Jakub T. Jankiewicz; +Cc: Toshi Umehara, emacs-devel, Eli Zaretskii
> One note about original solution in .emacs file that I used. It doesn't
> correctly handle #; it works only till the end of the line (it should comment
Side note, I just pushed a patch which should handle `#;` a bit better,
more specifically, we should hopefully handle nested `#;` comments correctly.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] Scheme-mode: Add support for regular expression literal
2024-04-01 5:24 ` Stefan Monnier
@ 2024-04-02 8:48 ` Toshi Umehara
0 siblings, 0 replies; 17+ messages in thread
From: Toshi Umehara @ 2024-04-02 8:48 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel, Eli Zaretskii, Jakub T. Jankiewicz
Thank you very much for your help.
I am really happy to have made a commitment to Emacs!
--
Toshi (Toshihiro Umehara)
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2024-04-02 8:48 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-23 2:40 [PATCH] Scheme-mode: Add support for regular expression literal Toshi Umehara
2024-03-23 14:28 ` Jakub T. Jankiewicz
2024-03-23 20:57 ` Stefan Monnier
2024-03-24 4:33 ` Toshi Umehara
2024-03-28 11:33 ` Jakub T. Jankiewicz
2024-03-28 12:40 ` Toshi Umehara
2024-03-28 23:43 ` Jakub T. Jankiewicz
2024-03-29 6:48 ` Eli Zaretskii
2024-03-29 11:09 ` Jakub T. Jankiewicz
2024-03-29 15:02 ` Toshi Umehara
2024-03-29 15:38 ` Eli Zaretskii
2024-03-30 0:48 ` Toshi Umehara
2024-04-01 6:17 ` Stefan Monnier
2024-03-30 7:59 ` Eli Zaretskii
2024-04-01 5:31 ` Stefan Monnier
2024-04-01 5:24 ` Stefan Monnier
2024-04-02 8:48 ` Toshi Umehara
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.