aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-05-20 16:12:30 -0400
committerStefan Monnier2014-05-20 16:12:30 -0400
commit0a5cfeeecb9e1038f9df3b34b61b797e56213a7b (patch)
tree73ed79276cb663c3e73e78d78857e76f4c9fdde1
parent7b952d6142f5c611312761c0ad853deb453bbe88 (diff)
downloademacs-0a5cfeeecb9e1038f9df3b34b61b797e56213a7b.tar.gz
emacs-0a5cfeeecb9e1038f9df3b34b61b797e56213a7b.zip
* lisp/progmodes/scheme.el (scheme-mode-syntax-table): Remove hack for
#; comments. (scheme-syntax-propertize, scheme-syntax-propertize-sexp-comment): New functions. (scheme-mode-variables): Set syntax-propertize-function instead of font-lock-syntactic-face-function. (scheme-font-lock-syntactic-face-function): Delete.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/scheme.el58
2 files changed, 35 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 33700a238e1..9374f20aacc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12014-05-20 Stefan Monnier <monnier@iro.umontreal.ca> 12014-05-20 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/scheme.el (scheme-mode-syntax-table): Remove hack for
4 #; comments.
5 (scheme-syntax-propertize, scheme-syntax-propertize-sexp-comment):
6 New functions.
7 (scheme-mode-variables): Set syntax-propertize-function instead of
8 font-lock-syntactic-face-function.
9 (scheme-font-lock-syntactic-face-function): Delete.
10
3 * emacs-lisp/lisp.el (end-of-defun): Ensure we move (bug#17274). 11 * emacs-lisp/lisp.el (end-of-defun): Ensure we move (bug#17274).
4 12
52014-05-18 Stefan Monnier <monnier@iro.umontreal.ca> 132014-05-18 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index da0b6edf302..5ad5633fa85 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -99,7 +99,7 @@
99 (modify-syntax-entry ?\( "() " st) 99 (modify-syntax-entry ?\( "() " st)
100 (modify-syntax-entry ?\) ")( " st) 100 (modify-syntax-entry ?\) ")( " st)
101 ;; It's used for single-line comments as well as for #;(...) sexp-comments. 101 ;; It's used for single-line comments as well as for #;(...) sexp-comments.
102 (modify-syntax-entry ?\; "< 2 " st) 102 (modify-syntax-entry ?\; "<" st)
103 (modify-syntax-entry ?\" "\" " st) 103 (modify-syntax-entry ?\" "\" " st)
104 (modify-syntax-entry ?' "' " st) 104 (modify-syntax-entry ?' "' " st)
105 (modify-syntax-entry ?` "' " st) 105 (modify-syntax-entry ?` "' " st)
@@ -147,19 +147,15 @@
147 (setq-local lisp-indent-function 'scheme-indent-function) 147 (setq-local lisp-indent-function 'scheme-indent-function)
148 (setq mode-line-process '("" scheme-mode-line-process)) 148 (setq mode-line-process '("" scheme-mode-line-process))
149 (setq-local imenu-case-fold-search t) 149 (setq-local imenu-case-fold-search t)
150 (setq imenu-generic-expression scheme-imenu-generic-expression) 150 (setq-local imenu-generic-expression scheme-imenu-generic-expression)
151 (setq-local imenu-syntax-alist 151 (setq-local imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w")))
152 '(("+-*/.<>=?!$%_&~^:" . "w"))) 152 (setq-local syntax-propertize-function #'scheme-syntax-propertize)
153 (setq font-lock-defaults 153 (setq font-lock-defaults
154 '((scheme-font-lock-keywords 154 '((scheme-font-lock-keywords
155 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) 155 scheme-font-lock-keywords-1 scheme-font-lock-keywords-2)
156 nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) 156 nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14"))
157 beginning-of-defun 157 beginning-of-defun
158 (font-lock-mark-block-function . mark-defun) 158 (font-lock-mark-block-function . mark-defun)))
159 (font-lock-syntactic-face-function
160 . scheme-font-lock-syntactic-face-function)
161 (parse-sexp-lookup-properties . t)
162 (font-lock-extra-managed-props syntax-table)))
163 (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt)) 159 (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt))
164 160
165(defvar scheme-mode-line-process "") 161(defvar scheme-mode-line-process "")
@@ -352,28 +348,28 @@ See `run-hooks'."
352 (forward-comment (point-max)) 348 (forward-comment (point-max))
353 (if (eq (char-after) ?\() 2 0))) 349 (if (eq (char-after) ?\() 2 0)))
354 350
355(defun scheme-font-lock-syntactic-face-function (state) 351(defun scheme-syntax-propertize (beg end)
356 (when (and (null (nth 3 state)) 352 (goto-char beg)
357 (eq (char-after (nth 8 state)) ?#) 353 (scheme-syntax-propertize-sexp-comment (point) end)
358 (eq (char-after (1+ (nth 8 state))) ?\;)) 354 (funcall
359 ;; It's a sexp-comment. Tell parse-partial-sexp where it ends. 355 (syntax-propertize-rules
360 (save-excursion 356 ("\\(#\\);" (1 (prog1 "< cn"
361 (let ((pos (point)) 357 (scheme-syntax-propertize-sexp-comment (point) end)))))
362 (end 358 (point) end))
363 (condition-case err 359
364 (let ((parse-sexp-lookup-properties nil)) 360(defun scheme-syntax-propertize-sexp-comment (_ end)
365 (goto-char (+ 2 (nth 8 state))) 361 (let ((state (syntax-ppss)))
366 ;; FIXME: this doesn't handle the case where the sexp 362 (when (eq 2 (nth 7 state))
367 ;; itself contains a #; comment. 363 ;; It's a sexp-comment. Tell parse-partial-sexp where it ends.
368 (forward-sexp 1) 364 (condition-case nil
369 (point)) 365 (progn
370 (scan-error (nth 2 err))))) 366 (goto-char (+ 2 (nth 8 state)))
371 (when (< pos (- end 2)) 367 ;; FIXME: this doesn't handle the case where the sexp
372 (put-text-property pos (- end 2) 368 ;; itself contains a #; comment.
373 'syntax-table scheme-sexp-comment-syntax-table)) 369 (forward-sexp 1)
374 (put-text-property (- end 1) end 'syntax-table '(12))))) 370 (put-text-property (1- (point)) (point)
375 ;; Choose the face to use. 371 'syntax-table (string-to-syntax "> cn")))
376 (lisp-font-lock-syntactic-face-function state)) 372 (scan-error (goto-char end))))))
377 373
378;;;###autoload 374;;;###autoload
379(define-derived-mode dsssl-mode scheme-mode "DSSSL" 375(define-derived-mode dsssl-mode scheme-mode "DSSSL"