changeset 65850:125c8f7cc7d2

(scheme-mode-syntax-table): Move the nesting bit from # to |. (scheme-font-lock-syntactic-face-function): New function, to distinguish strings from |...| symbols. (scheme-mode-variables): Use it. Also fix up the font-lock-time syntax-table so that #|...|# is properly highlighted.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 05 Oct 2005 14:23:13 +0000
parents e7b6d13be107
children c9b01535e163
files lisp/progmodes/scheme.el
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/scheme.el	Wed Oct 05 14:07:18 2005 +0000
+++ b/lisp/progmodes/scheme.el	Wed Oct 05 14:23:13 2005 +0000
@@ -90,7 +90,12 @@
     (modify-syntax-entry ?\] ")[  " st)
     (modify-syntax-entry ?{ "(}  " st)
     (modify-syntax-entry ?} "){  " st)
-    (modify-syntax-entry ?\| "\" 23b" st)
+    (modify-syntax-entry ?\| "\" 23bn" st)
+    ;; Guile allows #! ... !# comments.
+    ;; But SRFI-22 defines the comment as #!...\n instead.
+    ;; Also Guile says that the !# should be on a line of its own.
+    ;; It's too difficult to get it right, for too little benefit.
+    ;; (modify-syntax-entry ?! "_ 2" st)
 
     ;; Other atom delimiters
     (modify-syntax-entry ?\( "()  " st)
@@ -103,7 +108,7 @@
     ;; Special characters
     (modify-syntax-entry ?, "'   " st)
     (modify-syntax-entry ?@ "'   " st)
-    (modify-syntax-entry ?# "' 14bn" st)
+    (modify-syntax-entry ?# "' 14b" st)
     (modify-syntax-entry ?\\ "\\   " st)
     st))
 
@@ -167,9 +172,11 @@
   (setq font-lock-defaults
         '((scheme-font-lock-keywords
            scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
-          nil t (("+-*/.<>=!?$%_&~^:#" . "w")) beginning-of-defun
+          nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14"))
+          beginning-of-defun
           (font-lock-mark-block-function . mark-defun)
-          (font-lock-syntactic-face-function . lisp-font-lock-syntactic-face-function))))
+          (font-lock-syntactic-face-function
+           . scheme-font-lock-syntactic-face-function))))
 
 (defvar scheme-mode-line-process "")
 
@@ -345,6 +352,16 @@
 (defvar scheme-font-lock-keywords scheme-font-lock-keywords-1
   "Default expressions to highlight in Scheme modes.")
 
+(defun scheme-font-lock-syntactic-face-function (state)
+  (if (nth 3 state)
+      ;; In a string.
+      (if (eq (char-after (nth 8 state)) ?|)
+          ;; This is not a string, but a |...| symbol.
+          nil
+        font-lock-string-face)
+    ;; In a comment.
+    font-lock-comment-face))
+
 ;;;###autoload
 (define-derived-mode dsssl-mode scheme-mode "DSSSL"
   "Major mode for editing DSSSL code.