aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1995-07-09 13:26:41 +0000
committerSimon Marshall1995-07-09 13:26:41 +0000
commitbda609416b33b64a5a50b884e77fb8a8185c0405 (patch)
tree045fc97b87bef4db2c9b9f7ce8a466dd88cdb11d
parent591655c7ab9f80c5a7b0532396f9706ddf07868c (diff)
downloademacs-bda609416b33b64a5a50b884e77fb8a8185c0405.tar.gz
emacs-bda609416b33b64a5a50b884e77fb8a8185c0405.zip
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.
-rw-r--r--lisp/font-lock.el73
1 files changed, 35 insertions, 38 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index f451d3aecfa..51cdb033d28 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -85,8 +85,6 @@
85(defvar font-lock-no-comments nil 85(defvar font-lock-no-comments nil
86 "Non-nil means Font Lock should not fontify comments or strings.") 86 "Non-nil means Font Lock should not fontify comments or strings.")
87 87
88(make-obsolete-variable 'font-lock-doc-string-face 'font-lock-string-face)
89
90(make-variable-buffer-local 'font-lock-keywords) 88(make-variable-buffer-local 'font-lock-keywords)
91(defvar font-lock-keywords nil 89(defvar font-lock-keywords nil
92 "*The keywords to highlight. 90 "*The keywords to highlight.
@@ -462,12 +460,12 @@ the face is also set; its value is the face name."
462 ;; Make sure PREV is non-nil after the loop 460 ;; Make sure PREV is non-nil after the loop
463 ;; only if it was set on the very last iteration. 461 ;; only if it was set on the very last iteration.
464 (setq prev nil))) 462 (setq prev nil)))
465 (set-syntax-table old-syntax)) 463 (set-syntax-table old-syntax)
466 (and prev 464 (and prev
467 (remove-text-properties prev end '(face nil))) 465 (remove-text-properties prev end '(face nil)))
468 (and (buffer-modified-p) 466 (and (buffer-modified-p)
469 (not modified) 467 (not modified)
470 (set-buffer-modified-p nil)))))) 468 (set-buffer-modified-p nil)))))))
471 469
472 470
473(defun font-lock-unfontify-region (beg end) 471(defun font-lock-unfontify-region (beg end)
@@ -582,10 +580,10 @@ the face is also set; its value is the face name."
582 (mapcar 'font-lock-apply-highlight highlights)) 580 (mapcar 'font-lock-apply-highlight highlights))
583 (if loudly (message "Fontifying %s... (regexps...%s)" bufname 581 (if loudly (message "Fontifying %s... (regexps...%s)" bufname
584 (make-string (setq count (1+ count)) ?.))))) 582 (make-string (setq count (1+ count)) ?.)))))
585 (set-syntax-table old-syntax)) 583 (set-syntax-table old-syntax)
586 (and (buffer-modified-p) 584 (and (buffer-modified-p)
587 (not modified) 585 (not modified)
588 (set-buffer-modified-p nil)))) 586 (set-buffer-modified-p nil)))))
589 587
590;; The user level functions 588;; The user level functions
591 589
@@ -666,10 +664,10 @@ size, you can use \\[font-lock-fontify-buffer]."
666 "Unconditionally turn on Font Lock mode." 664 "Unconditionally turn on Font Lock mode."
667 (font-lock-mode 1)) 665 (font-lock-mode 1))
668 666
669;; Turn off other related packages if they're on. I prefer a hook. 667;; Turn off other related packages if they're on. I prefer a hook. --sm.
670;; These explicit calls are easier to understand 668;; These explicit calls are easier to understand
671;; because people know what they will do. 669;; because people know what they will do.
672;; A hook is a mystery because it might do anything whatever. -- rms. 670;; A hook is a mystery because it might do anything whatever. --rms.
673(defun font-lock-thing-lock-cleanup () 671(defun font-lock-thing-lock-cleanup ()
674 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) 672 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
675 (fast-lock-mode -1)) 673 (fast-lock-mode -1))
@@ -743,27 +741,21 @@ size, you can use \\[font-lock-fontify-buffer]."
743 (let ((word-char "[-+a-zA-Z0-9_:*]")) 741 (let ((word-char "[-+a-zA-Z0-9_:*]"))
744 (list 742 (list
745 ;; 743 ;;
746 ;; Control structures. 744 ;; Control structures. ELisp and CLisp combined.
747 ;; ELisp:
748; ("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw" 745; ("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw"
749; "save-restriction" "save-excursion" "save-window-excursion" 746; "save-restriction" "save-excursion" "save-window-excursion"
750; "save-selected-window" "save-match-data" "unwind-protect" 747; "save-selected-window" "save-match-data" "unwind-protect"
751; "condition-case" "track-mouse") 748; "condition-case" "track-mouse"
749; "when" "unless" "do" "flet" "labels" "return" "return-from")
752 (cons 750 (cons
753 (concat 751 (concat
754 "(\\(" 752 "(\\("
755 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|if\\|let\\*?\\|prog[nv12*]?\\|" 753 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|flet\\|if\\|"
754 "l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|return\\(\\|-from\\)\\|"
756 "save-\\(excursion\\|match-data\\|restriction\\|" 755 "save-\\(excursion\\|match-data\\|restriction\\|"
757 "selected-window\\|window-excursion\\)\\|" 756 "selected-window\\|window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|"
758 "t\\(hrow\\|rack-mouse\\)\\|unwind-protect\\|while" 757 "un\\(less\\|wind-protect\\)\\|wh\\(en\\|ile\\)"
759 "\\)\\>") 1) 758 "\\)\\>") 1)
760 ;; CLisp:
761; ("when" "unless" "do" "flet" "labels" "return" "return-from")
762 '("(\\(do\\|flet\\|labels\\|return\\(\\|-from\\)\\|unless\\|when\\)\\>"
763 . 1)
764 ;;
765 ;; Fontify CLisp keywords.
766 (concat "\\<:" word-char "+\\>")
767 ;; 759 ;;
768 ;; Function names in emacs-lisp docstrings (in the syntax that 760 ;; Function names in emacs-lisp docstrings (in the syntax that
769 ;; `substitute-command-keys' understands). 761 ;; `substitute-command-keys' understands).
@@ -774,7 +766,10 @@ size, you can use \\[font-lock-fontify-buffer]."
774 (list (concat "`\\(" word-char word-char "+\\)'") 766 (list (concat "`\\(" word-char word-char "+\\)'")
775 1 'font-lock-reference-face t) 767 1 'font-lock-reference-face t)
776 ;; 768 ;;
777 ;; & keywords as types 769 ;; CLisp `:' keywords as references.
770 (list (concat "\\<:" word-char "+\\>") 0 font-lock-reference-face t)
771 ;;
772 ;; ELisp and CLisp `&' keywords as types.
778 '("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face) 773 '("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face)
779 ))) 774 )))
780 "Gaudy level highlighting for Lisp modes.") 775 "Gaudy level highlighting for Lisp modes.")
@@ -933,14 +928,14 @@ size, you can use \\[font-lock-fontify-buffer]."
933(defun font-lock-choose-keywords (keywords level) 928(defun font-lock-choose-keywords (keywords level)
934 ;; Return evaled LEVELth element of KEYWORDS. A LEVEL of nil is equal to a 929 ;; Return evaled LEVELth element of KEYWORDS. A LEVEL of nil is equal to a
935 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)). 930 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)).
936 (eval (cond ((symbolp keywords) 931 (cond ((symbolp keywords)
937 keywords) 932 keywords)
938 ((numberp level) 933 ((numberp level)
939 (or (nth level keywords) (car (reverse keywords)))) 934 (or (nth level keywords) (car (reverse keywords))))
940 ((eq level t) 935 ((eq level t)
941 (car (reverse keywords))) 936 (car (reverse keywords)))
942 (t 937 (t
943 (car keywords))))) 938 (car keywords))))
944 939
945(defun font-lock-set-defaults () 940(defun font-lock-set-defaults ()
946 "Set fontification defaults appropriately for this mode. 941 "Set fontification defaults appropriately for this mode.
@@ -954,8 +949,10 @@ nil, using `font-lock-defaults-alist') and `font-lock-maximum-decoration'."
954 (let ((defaults (or font-lock-defaults 949 (let ((defaults (or font-lock-defaults
955 (cdr (assq major-mode font-lock-defaults-alist))))) 950 (cdr (assq major-mode font-lock-defaults-alist)))))
956 ;; Keywords? 951 ;; Keywords?
957 (setq font-lock-keywords (font-lock-choose-keywords (nth 0 defaults) 952 (setq font-lock-keywords
958 font-lock-maximum-decoration)) 953 (font-lock-compile-keywords
954 (eval (font-lock-choose-keywords (nth 0 defaults)
955 font-lock-maximum-decoration))))
959 ;; Syntactic? 956 ;; Syntactic?
960 (if (nth 1 defaults) 957 (if (nth 1 defaults)
961 (set (make-local-variable 'font-lock-no-comments) t)) 958 (set (make-local-variable 'font-lock-no-comments) t))