aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-10-05 15:31:44 +0000
committerStefan Monnier2005-10-05 15:31:44 +0000
commit21c3ef84cc73ded6aa4882afe3e93bc7bd81aca7 (patch)
tree3dfff8469c455981f38bc31ad0c90ce65e8f3043
parentd95af087de80d8309b92b38122451e660df0e398 (diff)
downloademacs-21c3ef84cc73ded6aa4882afe3e93bc7bd81aca7.tar.gz
emacs-21c3ef84cc73ded6aa4882afe3e93bc7bd81aca7.zip
(scheme-mode-syntax-table): Mark ; as being also the
second char of a comment-start sequence. (scheme-sexp-comment-syntax-table): New var. (lambda, define): Set their scheme-doc-string-elt property. (scheme-font-lock-syntactic-face-function): Handle sexp-comments. Use lisp-font-lock-syntactic-face-function now that it properly handles |...| symbols. (scheme-mode-variables): Set lisp-doc-string-elt-property, parse-sexp-lookup-properties and font-lock-extra-managed-props.
-rw-r--r--lisp/ChangeLog31
-rw-r--r--lisp/progmodes/scheme.el70
2 files changed, 82 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b713d5d2df9..a9d8a3923d6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,34 @@
12005-10-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/scheme.el (scheme-mode-syntax-table): Mark ; as being
4 also the second char of a comment-start sequence.
5 (scheme-sexp-comment-syntax-table): New var.
6 (lambda, define): Set their scheme-doc-string-elt property.
7 (scheme-font-lock-syntactic-face-function): Handle sexp-comments.
8 Use lisp-font-lock-syntactic-face-function now that it properly
9 handles |...| symbols.
10 (scheme-mode-variables): Set lisp-doc-string-elt-property,
11 parse-sexp-lookup-properties and font-lock-extra-managed-props.
12
13 * emacs-lisp/lisp-mode.el (lisp-mode-syntax-table): Move the nesting
14 bit from # to |.
15 (lisp-font-lock-syntactic-face-function): Distinguish |...| symbols.
16
17 * emacs-lisp/lisp-mode.el (lambda): Add its doc-string-elt property.
18 (lisp-doc-string-elt-property): New var.
19 (lisp-font-lock-syntactic-face-function): Use it.
20 Rewrite to recognize docstrings even for forms not at toplevel.
21
22 * progmodes/scheme.el (scheme-mode-syntax-table): Put the nested
23 annotation on the | part of #| rather than on the # part.
24 (scheme-font-lock-syntactic-face-function): New function, to
25 distinguish strings from |...| symbols.
26 (scheme-mode-variables): Use it. Also fix up the font-lock-time
27 syntax-table so that #|...|# is properly highlighted.
28
29 * emacs-lisp/lisp-mode.el (lisp-font-lock-syntactic-face-function):
30 Don't mark as docstring the 3rd elem of an unknown toplevel form.
31
12005-10-04 Stefan Monnier <monnier@iro.umontreal.ca> 322005-10-04 Stefan Monnier <monnier@iro.umontreal.ca>
2 33
3 * bindings.el (global-map): Resync [home] and [end] bindings with C-a 34 * bindings.el (global-map): Resync [home] and [end] bindings with C-a
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index cae3ac582ef..15ab8edaadc 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -100,8 +100,9 @@
100 ;; Other atom delimiters 100 ;; Other atom delimiters
101 (modify-syntax-entry ?\( "() " st) 101 (modify-syntax-entry ?\( "() " st)
102 (modify-syntax-entry ?\) ")( " st) 102 (modify-syntax-entry ?\) ")( " st)
103 (modify-syntax-entry ?\; "< " st) 103 ;; It's used for single-line comments as well as for #;(...) sexp-comments.
104 (modify-syntax-entry ?\" "\" " st) 104 (modify-syntax-entry ?\; "< 2 " st)
105 (modify-syntax-entry ?\" "\" " st)
105 (modify-syntax-entry ?' "' " st) 106 (modify-syntax-entry ?' "' " st)
106 (modify-syntax-entry ?` "' " st) 107 (modify-syntax-entry ?` "' " st)
107 108
@@ -168,15 +169,18 @@
168 (setq imenu-generic-expression scheme-imenu-generic-expression) 169 (setq imenu-generic-expression scheme-imenu-generic-expression)
169 (set (make-local-variable 'imenu-syntax-alist) 170 (set (make-local-variable 'imenu-syntax-alist)
170 '(("+-*/.<>=?!$%_&~^:" . "w"))) 171 '(("+-*/.<>=?!$%_&~^:" . "w")))
171 (make-local-variable 'font-lock-defaults) 172 (set (make-local-variable 'font-lock-defaults)
172 (setq font-lock-defaults 173 '((scheme-font-lock-keywords
173 '((scheme-font-lock-keywords 174 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
174 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) 175 nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14"))
175 nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) 176 beginning-of-defun
176 beginning-of-defun 177 (font-lock-mark-block-function . mark-defun)
177 (font-lock-mark-block-function . mark-defun) 178 (font-lock-syntactic-face-function
178 (font-lock-syntactic-face-function 179 . scheme-font-lock-syntactic-face-function)
179 . scheme-font-lock-syntactic-face-function)))) 180 (parse-sexp-lookup-properties . t)
181 (font-lock-extra-managed-props syntax-table)))
182 (set (make-local-variable 'lisp-doc-string-elt-property)
183 'scheme-doc-string-elt))
180 184
181(defvar scheme-mode-line-process "") 185(defvar scheme-mode-line-process "")
182 186
@@ -352,15 +356,43 @@ See `run-hooks'."
352(defvar scheme-font-lock-keywords scheme-font-lock-keywords-1 356(defvar scheme-font-lock-keywords scheme-font-lock-keywords-1
353 "Default expressions to highlight in Scheme modes.") 357 "Default expressions to highlight in Scheme modes.")
354 358
359(defconst scheme-sexp-comment-syntax-table
360 (let ((st (make-syntax-table scheme-mode-syntax-table)))
361 (modify-syntax-entry ?\; "." st)
362 (modify-syntax-entry ?\n " " st)
363 (modify-syntax-entry ?# "'" st)
364 st))
365
366(put 'lambda 'scheme-doc-string-elt 2)
367;; Docstring's pos in a `define' depends on whether it's a var or fun def.
368(put 'define 'scheme-doc-string-elt
369 (lambda ()
370 ;; The function is called with point right after "define".
371 (forward-comment (point-max))
372 (if (eq (char-after) ?\() 2 0)))
373
355(defun scheme-font-lock-syntactic-face-function (state) 374(defun scheme-font-lock-syntactic-face-function (state)
356 (if (nth 3 state) 375 (when (and (null (nth 3 state))
357 ;; In a string. 376 (eq (char-after (nth 8 state)) ?#)
358 (if (eq (char-after (nth 8 state)) ?|) 377 (eq (char-after (1+ (nth 8 state))) ?\;))
359 ;; This is not a string, but a |...| symbol. 378 ;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
360 nil 379 (save-excursion
361 font-lock-string-face) 380 (let ((pos (point))
362 ;; In a comment. 381 (end
363 font-lock-comment-face)) 382 (condition-case err
383 (let ((parse-sexp-lookup-properties nil))
384 (goto-char (+ 2 (nth 8 state)))
385 ;; FIXME: this doesn't handle the case where the sexp
386 ;; itself contains a #; comment.
387 (forward-sexp 1)
388 (point))
389 (scan-error (nth 2 err)))))
390 (when (< pos (- end 2))
391 (put-text-property pos (- end 2)
392 'syntax-table scheme-sexp-comment-syntax-table))
393 (put-text-property (- end 1) end 'syntax-table '(12)))))
394 ;; Choose the face to use.
395 (lisp-font-lock-syntactic-face-function state))
364 396
365;;;###autoload 397;;;###autoload
366(define-derived-mode dsssl-mode scheme-mode "DSSSL" 398(define-derived-mode dsssl-mode scheme-mode "DSSSL"