aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniceume2024-03-17 09:12:32 +0900
committerStefan Monnier2024-04-01 01:23:18 -0400
commit02c2a95a52e53486d034de4cd2831b258a49f9c4 (patch)
treed4af9106443278bf50bce026650d7ad8724e1a01
parent0cf9b58228580bfa400cdaf35eac04d375fe4785 (diff)
downloademacs-02c2a95a52e53486d034de4cd2831b258a49f9c4.tar.gz
emacs-02c2a95a52e53486d034de4cd2831b258a49f9c4.zip
scheme.el: Enable dealing with regular expression literal
* lisp/progmodes/scheme.el (scheme-syntax-propertize-regexp): New function. (scheme-syntax-propertize): Use it.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/progmodes/scheme.el27
2 files changed, 31 insertions, 1 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 775c8e02a95..1b86a968c5d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1218,6 +1218,11 @@ instead of:
1218This allows the user to specify command line arguments to the non 1218This allows the user to specify command line arguments to the non
1219interactive Python interpreter specified by 'python-interpreter'. 1219interactive Python interpreter specified by 'python-interpreter'.
1220 1220
1221** Scheme mode
1222
1223Scheme mode now handles regular expression literal #/regexp/ that is
1224available in some Scheme implementations.
1225
1221** use-package 1226** use-package
1222 1227
1223+++ 1228+++
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 67abab6913d..dc46f0fbbb8 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -410,10 +410,19 @@ See `run-hooks'."
410(defun scheme-syntax-propertize (beg end) 410(defun scheme-syntax-propertize (beg end)
411 (goto-char beg) 411 (goto-char beg)
412 (scheme-syntax-propertize-sexp-comment (point) end) 412 (scheme-syntax-propertize-sexp-comment (point) end)
413 (scheme-syntax-propertize-regexp end)
413 (funcall 414 (funcall
414 (syntax-propertize-rules 415 (syntax-propertize-rules
415 ("\\(#\\);" (1 (prog1 "< cn" 416 ("\\(#\\);" (1 (prog1 "< cn"
416 (scheme-syntax-propertize-sexp-comment (point) end))))) 417 (scheme-syntax-propertize-sexp-comment (point) end))))
418 ("\\(#\\)/" (1 (when (null (nth 8 (save-excursion
419 (syntax-ppss (match-beginning 0)))))
420 (put-text-property
421 (match-beginning 1)
422 (match-end 1)
423 'syntax-table (string-to-syntax "|"))
424 (scheme-syntax-propertize-regexp end)
425 nil))))
417 (point) end)) 426 (point) end))
418 427
419(defun scheme-syntax-propertize-sexp-comment (_ end) 428(defun scheme-syntax-propertize-sexp-comment (_ end)
@@ -430,6 +439,22 @@ See `run-hooks'."
430 'syntax-table (string-to-syntax "> cn"))) 439 'syntax-table (string-to-syntax "> cn")))
431 (scan-error (goto-char end)))))) 440 (scan-error (goto-char end))))))
432 441
442(defun scheme-syntax-propertize-regexp (end)
443 (let* ((state (syntax-ppss))
444 (within-str (nth 3 state))
445 (start-delim-pos (nth 8 state)))
446 (when (and within-str
447 (char-equal ?# (char-after start-delim-pos)))
448 (while (and (re-search-forward "/" end 'move)
449 (eq -1
450 (% (save-excursion
451 (backward-char)
452 (skip-chars-backward "\\\\"))
453 2))))
454 (when (< (point) end)
455 (put-text-property (match-beginning 0) (match-end 0)
456 'syntax-table (string-to-syntax "|"))))))
457
433;;;###autoload 458;;;###autoload
434(define-derived-mode dsssl-mode scheme-mode "DSSSL" 459(define-derived-mode dsssl-mode scheme-mode "DSSSL"
435 "Major mode for editing DSSSL code. 460 "Major mode for editing DSSSL code.