Mercurial > emacs
changeset 12512:997e250dfe12
Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
their unwind-protect UNWINDFORMS. Also eval inside font-lock-set-defaults, not
font-lock-choose-keywords.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Sun, 09 Jul 1995 13:26:41 +0000 |
parents | 93a7cb2eefcc |
children | 7dd018689647 |
files | lisp/font-lock.el |
diffstat | 1 files changed, 35 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/font-lock.el Sun Jul 09 13:01:31 1995 +0000 +++ b/lisp/font-lock.el Sun Jul 09 13:26:41 1995 +0000 @@ -85,8 +85,6 @@ (defvar font-lock-no-comments nil "Non-nil means Font Lock should not fontify comments or strings.") -(make-obsolete-variable 'font-lock-doc-string-face 'font-lock-string-face) - (make-variable-buffer-local 'font-lock-keywords) (defvar font-lock-keywords nil "*The keywords to highlight. @@ -462,12 +460,12 @@ ;; Make sure PREV is non-nil after the loop ;; only if it was set on the very last iteration. (setq prev nil))) - (set-syntax-table old-syntax)) - (and prev - (remove-text-properties prev end '(face nil))) - (and (buffer-modified-p) - (not modified) - (set-buffer-modified-p nil)))))) + (set-syntax-table old-syntax) + (and prev + (remove-text-properties prev end '(face nil))) + (and (buffer-modified-p) + (not modified) + (set-buffer-modified-p nil))))))) (defun font-lock-unfontify-region (beg end) @@ -582,10 +580,10 @@ (mapcar 'font-lock-apply-highlight highlights)) (if loudly (message "Fontifying %s... (regexps...%s)" bufname (make-string (setq count (1+ count)) ?.))))) - (set-syntax-table old-syntax)) - (and (buffer-modified-p) - (not modified) - (set-buffer-modified-p nil)))) + (set-syntax-table old-syntax) + (and (buffer-modified-p) + (not modified) + (set-buffer-modified-p nil))))) ;; The user level functions @@ -666,10 +664,10 @@ "Unconditionally turn on Font Lock mode." (font-lock-mode 1)) -;; Turn off other related packages if they're on. I prefer a hook. +;; Turn off other related packages if they're on. I prefer a hook. --sm. ;; These explicit calls are easier to understand ;; because people know what they will do. -;; A hook is a mystery because it might do anything whatever. -- rms. +;; A hook is a mystery because it might do anything whatever. --rms. (defun font-lock-thing-lock-cleanup () (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) (fast-lock-mode -1)) @@ -743,27 +741,21 @@ (let ((word-char "[-+a-zA-Z0-9_:*]")) (list ;; - ;; Control structures. - ;; ELisp: + ;; Control structures. ELisp and CLisp combined. ; ("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw" ; "save-restriction" "save-excursion" "save-window-excursion" ; "save-selected-window" "save-match-data" "unwind-protect" -; "condition-case" "track-mouse") +; "condition-case" "track-mouse" +; "when" "unless" "do" "flet" "labels" "return" "return-from") (cons (concat "(\\(" - "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|if\\|let\\*?\\|prog[nv12*]?\\|" + "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|flet\\|if\\|" + "l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|return\\(\\|-from\\)\\|" "save-\\(excursion\\|match-data\\|restriction\\|" - "selected-window\\|window-excursion\\)\\|" - "t\\(hrow\\|rack-mouse\\)\\|unwind-protect\\|while" + "selected-window\\|window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|" + "un\\(less\\|wind-protect\\)\\|wh\\(en\\|ile\\)" "\\)\\>") 1) - ;; CLisp: -; ("when" "unless" "do" "flet" "labels" "return" "return-from") - '("(\\(do\\|flet\\|labels\\|return\\(\\|-from\\)\\|unless\\|when\\)\\>" - . 1) - ;; - ;; Fontify CLisp keywords. - (concat "\\<:" word-char "+\\>") ;; ;; Function names in emacs-lisp docstrings (in the syntax that ;; `substitute-command-keys' understands). @@ -774,7 +766,10 @@ (list (concat "`\\(" word-char word-char "+\\)'") 1 'font-lock-reference-face t) ;; - ;; & keywords as types + ;; CLisp `:' keywords as references. + (list (concat "\\<:" word-char "+\\>") 0 font-lock-reference-face t) + ;; + ;; ELisp and CLisp `&' keywords as types. '("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face) ))) "Gaudy level highlighting for Lisp modes.") @@ -933,14 +928,14 @@ (defun font-lock-choose-keywords (keywords level) ;; Return evaled LEVELth element of KEYWORDS. A LEVEL of nil is equal to a ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)). - (eval (cond ((symbolp keywords) - keywords) - ((numberp level) - (or (nth level keywords) (car (reverse keywords)))) - ((eq level t) - (car (reverse keywords))) - (t - (car keywords))))) + (cond ((symbolp keywords) + keywords) + ((numberp level) + (or (nth level keywords) (car (reverse keywords)))) + ((eq level t) + (car (reverse keywords))) + (t + (car keywords)))) (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode. @@ -954,8 +949,10 @@ (let ((defaults (or font-lock-defaults (cdr (assq major-mode font-lock-defaults-alist))))) ;; Keywords? - (setq font-lock-keywords (font-lock-choose-keywords (nth 0 defaults) - font-lock-maximum-decoration)) + (setq font-lock-keywords + (font-lock-compile-keywords + (eval (font-lock-choose-keywords (nth 0 defaults) + font-lock-maximum-decoration)))) ;; Syntactic? (if (nth 1 defaults) (set (make-local-variable 'font-lock-no-comments) t))