diff options
| author | Po Lu <luangruo@yahoo.com> | 2024-04-01 10:46:19 -0400 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2024-04-01 10:46:19 -0400 |
| commit | f53152faad170a93b7977c81f736cc787c2f9b71 (patch) | |
| tree | 8a4e7c12d211ccfc5aa045e5090791ab2dad2808 | |
| parent | 123bfc2779d52acfdb18e7fe64577645e227e1c2 (diff) | |
(scheme-syntax-propertize-sexp-comment): Allow `#;` in strings
* lisp/progmodes/scheme.el (scheme-syntax-propertize-sexp-comment):
Don't get confused by `#;` inside strings and (normal) comments.
(scheme-sexp-comment-syntax-table): Comment-out, unused.
| -rw-r--r-- | lisp/progmodes/scheme.el | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 79d076ff145..3242f1c345c 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -387,12 +387,12 @@ See `run-hooks'." (defvar scheme-font-lock-keywords scheme-font-lock-keywords-1 "Default expressions to highlight in Scheme modes.") -(defconst scheme-sexp-comment-syntax-table - (let ((st (make-syntax-table scheme-mode-syntax-table))) - (modify-syntax-entry ?\; "." st) - (modify-syntax-entry ?\n " " st) - (modify-syntax-entry ?# "'" st) - st)) +;; (defconst scheme-sexp-comment-syntax-table +;; (let ((st (make-syntax-table scheme-mode-syntax-table))) +;; (modify-syntax-entry ?\; "." st) +;; (modify-syntax-entry ?\n " " st) +;; (modify-syntax-entry ?# "'" st) +;; st)) (put 'lambda 'scheme-doc-string-elt 2) (put 'lambda* 'scheme-doc-string-elt 2) @@ -428,6 +428,7 @@ See `run-hooks'." (defun scheme-syntax-propertize-sexp-comment (end) (let ((state (syntax-ppss)) + ;; (beg (point)) (checked (point))) (when (eq 2 (nth 7 state)) ;; It's a sexp-comment. Tell parse-partial-sexp where it ends. @@ -437,9 +438,11 @@ See `run-hooks'." (progn (setq found nil) (condition-case nil - (progn + (save-restriction + (narrow-to-region (point-min) end) (goto-char startpos) (forward-sexp 1) + ;; (cl-assert (> (point) beg)) (setq found (point))) (scan-error (goto-char end))) ;; If there's a nested `#;', the syntax-tables will normally @@ -447,16 +450,22 @@ See `run-hooks'." ;; (forward-sexp 1) above may have landed at the wrong place. ;; So look for `#;' in the text over which we jumped, and ;; mark those we found as nested sexp-comments. - (let ((limit (or found end))) + (let ((limit (min end (or found end)))) (when (< checked limit) (goto-char checked) - (when (re-search-forward "\\(#\\);" limit 'move) - (setq checked (point)) + (while (and (re-search-forward "\\(#\\);" limit 'move) + ;; Skip those #; inside comments and strings. + (nth 8 (save-excursion + (parse-partial-sexp + startpos (match-beginning 0)))))) + (setq checked (point)) + (when (< (point) limit) (put-text-property (match-beginning 1) (match-end 1) 'syntax-table (string-to-syntax "< cn")) - (loop (point))) - (< (point) limit))))) + (loop (point)) + ;; Try the `forward-sexp' with the new text state. + t))))) (when found (goto-char found) (put-text-property (1- found) found |
