diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-05-20 16:12:30 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-05-20 16:12:30 -0400 |
commit | 0a5cfeeecb9e1038f9df3b34b61b797e56213a7b (patch) | |
tree | 73ed79276cb663c3e73e78d78857e76f4c9fdde1 | |
parent | 7b952d6142f5c611312761c0ad853deb453bbe88 (diff) | |
download | emacs-0a5cfeeecb9e1038f9df3b34b61b797e56213a7b.tar.gz |
* 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/ChangeLog | 8 | ||||
-rw-r--r-- | lisp/progmodes/scheme.el | 58 |
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 @@ 2014-05-20 Stefan Monnier <monnier@iro.umontreal.ca> + * 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. + * emacs-lisp/lisp.el (end-of-defun): Ensure we move (bug#17274). 2014-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 @@ (modify-syntax-entry ?\( "() " st) (modify-syntax-entry ?\) ")( " st) ;; It's used for single-line comments as well as for #;(...) sexp-comments. - (modify-syntax-entry ?\; "< 2 " st) + (modify-syntax-entry ?\; "<" st) (modify-syntax-entry ?\" "\" " st) (modify-syntax-entry ?' "' " st) (modify-syntax-entry ?` "' " st) @@ -147,19 +147,15 @@ (setq-local lisp-indent-function 'scheme-indent-function) (setq mode-line-process '("" scheme-mode-line-process)) (setq-local imenu-case-fold-search t) - (setq imenu-generic-expression scheme-imenu-generic-expression) - (setq-local imenu-syntax-alist - '(("+-*/.<>=?!$%_&~^:" . "w"))) + (setq-local imenu-generic-expression scheme-imenu-generic-expression) + (setq-local imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w"))) + (setq-local syntax-propertize-function #'scheme-syntax-propertize) (setq font-lock-defaults '((scheme-font-lock-keywords scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) beginning-of-defun - (font-lock-mark-block-function . mark-defun) - (font-lock-syntactic-face-function - . scheme-font-lock-syntactic-face-function) - (parse-sexp-lookup-properties . t) - (font-lock-extra-managed-props syntax-table))) + (font-lock-mark-block-function . mark-defun))) (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt)) (defvar scheme-mode-line-process "") @@ -352,28 +348,28 @@ See `run-hooks'." (forward-comment (point-max)) (if (eq (char-after) ?\() 2 0))) -(defun scheme-font-lock-syntactic-face-function (state) - (when (and (null (nth 3 state)) - (eq (char-after (nth 8 state)) ?#) - (eq (char-after (1+ (nth 8 state))) ?\;)) - ;; It's a sexp-comment. Tell parse-partial-sexp where it ends. - (save-excursion - (let ((pos (point)) - (end - (condition-case err - (let ((parse-sexp-lookup-properties nil)) - (goto-char (+ 2 (nth 8 state))) - ;; FIXME: this doesn't handle the case where the sexp - ;; itself contains a #; comment. - (forward-sexp 1) - (point)) - (scan-error (nth 2 err))))) - (when (< pos (- end 2)) - (put-text-property pos (- end 2) - 'syntax-table scheme-sexp-comment-syntax-table)) - (put-text-property (- end 1) end 'syntax-table '(12))))) - ;; Choose the face to use. - (lisp-font-lock-syntactic-face-function state)) +(defun scheme-syntax-propertize (beg end) + (goto-char beg) + (scheme-syntax-propertize-sexp-comment (point) end) + (funcall + (syntax-propertize-rules + ("\\(#\\);" (1 (prog1 "< cn" + (scheme-syntax-propertize-sexp-comment (point) end))))) + (point) end)) + +(defun scheme-syntax-propertize-sexp-comment (_ end) + (let ((state (syntax-ppss))) + (when (eq 2 (nth 7 state)) + ;; It's a sexp-comment. Tell parse-partial-sexp where it ends. + (condition-case nil + (progn + (goto-char (+ 2 (nth 8 state))) + ;; FIXME: this doesn't handle the case where the sexp + ;; itself contains a #; comment. + (forward-sexp 1) + (put-text-property (1- (point)) (point) + 'syntax-table (string-to-syntax "> cn"))) + (scan-error (goto-char end)))))) ;;;###autoload (define-derived-mode dsssl-mode scheme-mode "DSSSL" |