aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-11 09:03:49 +0000
committerRichard M. Stallman1994-10-11 09:03:49 +0000
commit2df1ee235231d56a60be2c2989969c08f58e8bc5 (patch)
treeea830f916d817c7a69553513b237813cf72ec9a3
parente87a730999bf986dae66de6c4ac020efc40dd57d (diff)
downloademacs-2df1ee235231d56a60be2c2989969c08f58e8bc5.tar.gz
emacs-2df1ee235231d56a60be2c2989969c08f58e8bc5.zip
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Use font-lock-defaults. (font-lock-defaults): New variable.
-rw-r--r--lisp/font-lock.el44
1 files changed, 25 insertions, 19 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 10b11ca0d08..8e6ddf3dfd4 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -807,30 +807,36 @@ where both MAJOR-MODE and FONT-LOCK-KEYWORDS are symbols. If NOT-SYNTACTICALLY
807is non-nil, syntactic fontification (strings and comments) is not performed. 807is non-nil, syntactic fontification (strings and comments) is not performed.
808If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying.") 808If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying.")
809 809
810(defvar font-lock-defaults nil
811 "If set by a major mode, this specifies the defaults for Font Lock mode.")
812
810(defun font-lock-set-defaults () 813(defun font-lock-set-defaults ()
811 "Set fontification defaults appropriately for this mode. 814 "Set fontification defaults appropriately for this mode.
812Sets `font-lock-keywords', `font-lock-keywords-case-fold-search' and 815Sets `font-lock-keywords', `font-lock-keywords-case-fold-search' and
813`font-lock-no-comments' using `font-lock-defaults-alist'. 816`font-lock-no-comments' using `font-lock-defaults-alist'.
814Also sets `font-lock-syntax-table' for C and C++ modes." 817Also sets `font-lock-syntax-table' for C and C++ modes."
815 (let ((defaults (cdr (assq major-mode font-lock-defaults-alist)))) 818 ;; If font-lock-keywords is already set, assume the major mode
816 ;; Keywords? 819 ;; has done exactly what it wants.
817 (if (not font-lock-keywords) ; if not already set. 820 (or font-lock-keywords
818 (setq font-lock-keywords (eval (nth 0 defaults)))) 821 (let ((defaults (or font-lock-defaults
819 ;; Syntactic? 822 (cdr (assq major-mode font-lock-defaults-alist)))))
820 (if (nth 1 defaults) 823 ;; Keywords?
821 (set (make-local-variable 'font-lock-no-comments) t)) 824 (setq font-lock-keywords (eval (nth 0 defaults)))
822 ;; Case fold? 825 ;; Syntactic?
823 (if (nth 2 defaults) 826 (if (nth 1 defaults)
824 (set (make-local-variable 'font-lock-keywords-case-fold-search) t)) 827 (set (make-local-variable 'font-lock-no-comments) t))
825 ;; Syntax table? 828 ;; Case fold?
826 (cond ((eq major-mode 'c-mode) 829 (if (nth 2 defaults)
827 (make-local-variable 'font-lock-syntax-table) 830 (set (make-local-variable 'font-lock-keywords-case-fold-search) t))
828 (setq font-lock-syntax-table (copy-syntax-table (syntax-table))) 831 ;; Syntax table?
829 (modify-syntax-entry ?_ "w" font-lock-syntax-table)) 832 (cond ((eq major-mode 'c-mode)
830 ((eq major-mode 'c++-c-mode) 833 (make-local-variable 'font-lock-syntax-table)
831 (make-local-variable 'font-lock-syntax-table) 834 (setq font-lock-syntax-table (copy-syntax-table (syntax-table)))
832 (setq font-lock-syntax-table (copy-syntax-table (syntax-table))) 835 (modify-syntax-entry ?_ "w" font-lock-syntax-table))
833 (modify-syntax-entry ?_ "w" font-lock-syntax-table))))) 836 ((eq major-mode 'c++-c-mode)
837 (make-local-variable 'font-lock-syntax-table)
838 (setq font-lock-syntax-table (copy-syntax-table (syntax-table)))
839 (modify-syntax-entry ?_ "w" font-lock-syntax-table))))))
834 840
835;; Install ourselves: 841;; Install ourselves:
836 842