Mercurial > emacs
comparison lisp/font-lock.el @ 9444:e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Use font-lock-defaults.
(font-lock-defaults): New variable.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 11 Oct 1994 09:03:49 +0000 |
parents | a7c6e2858f8b |
children | f80b2a33df03 |
comparison
equal
deleted
inserted
replaced
9443:5eaca32b6af6 | 9444:e21d4ebc3160 |
---|---|
805 (MAJOR-MODE . (FONT-LOCK-KEYWORDS NOT-SYNTACTICALLY CASE-FOLD) | 805 (MAJOR-MODE . (FONT-LOCK-KEYWORDS NOT-SYNTACTICALLY CASE-FOLD) |
806 where both MAJOR-MODE and FONT-LOCK-KEYWORDS are symbols. If NOT-SYNTACTICALLY | 806 where both MAJOR-MODE and FONT-LOCK-KEYWORDS are symbols. If NOT-SYNTACTICALLY |
807 is non-nil, syntactic fontification (strings and comments) is not performed. | 807 is non-nil, syntactic fontification (strings and comments) is not performed. |
808 If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying.") | 808 If 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. |
812 Sets `font-lock-keywords', `font-lock-keywords-case-fold-search' and | 815 Sets `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'. |
814 Also sets `font-lock-syntax-table' for C and C++ modes." | 817 Also 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 |
837 (mapcar 'font-lock-make-face font-lock-face-attributes) | 843 (mapcar 'font-lock-make-face font-lock-face-attributes) |
838 | 844 |