diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 67abab6913d..98405513099 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -410,11 +410,18 @@ 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 (point) end) (funcall (syntax-propertize-rules ("\\(#\\);" (1 (prog1 "< cn" - (scheme-syntax-propertize-sexp-comment (point) end))))) - (point) end)) + (scheme-syntax-propertize-sexp-comment + (point) end)))) + ("\\(#\\)/" (1 (prog1 "|" + (scheme-syntax-propertize-regexp + (point) end)))) + ) + (point) end) + ) (defun scheme-syntax-propertize-sexp-comment (_ end) (let ((state (syntax-ppss))) @@ -430,6 +437,49 @@ scheme-syntax-propertize-sexp-comment 'syntax-table (string-to-syntax "> cn"))) (scan-error (goto-char end)))))) +(defun scheme-syntax-propertize-regexp-end (_ end) + (let* ((state (syntax-ppss)) + (within-str (nth 3 state)) + (within-comm (nth 4 state)) + (start-delim-pos (nth 8 state))) + (if (and (not within-comm) + (and within-str + (string= + (buffer-substring-no-properties + start-delim-pos + (1+ start-delim-pos)) + "#"))) + (let ((end-found nil)) + (while (and + (not end-found) + (re-search-forward "\\(/\\)" end t)) + (progn + (if + (not (char-equal + (char-before (match-beginning 1)) + ?\\ )) + (progn + (put-text-property + (match-beginning 1) + (1+ (match-beginning 1)) + 'syntax-table (string-to-syntax "|")) + (setq end-found t) + ))))) + ))) + +(defun scheme-syntax-propertize-regexp (_ end) + (let* ((match-start-state (save-excursion + (syntax-ppss (match-beginning 1)))) + (within-str (nth 3 match-start-state)) + (within-comm (nth 4 match-start-state))) + (if (or within-str within-comm) + (put-text-property ;; Cancel regular expression start + (match-beginning 1) + (1+ (match-beginning 1)) + 'syntax-table (string-to-syntax "@")) + (scheme-syntax-propertize-regexp-end _ end) + ))) + ;;;###autoload (define-derived-mode dsssl-mode scheme-mode "DSSSL" "Major mode for editing DSSSL code.