/[emacs]/emacs/lisp/font-lock.el
ViewVC logotype

Diff of /emacs/lisp/font-lock.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.259 by rms, Sun May 29 08:39:40 2005 UTC revision 1.260 by teirllm, Sat Jun 4 22:23:44 2005 UTC
# Line 683  For example: Line 683  For example:
683  adds two fontification patterns for C mode, to fontify `FIXME:' words, even in  adds two fontification patterns for C mode, to fontify `FIXME:' words, even in
684  comments, and to fontify `and', `or' and `not' words as keywords.  comments, and to fontify `and', `or' and `not' words as keywords.
685    
686  When used from a Lisp program (such as a minor mode), it is recommended to  The above procedure will only add the keywords for C mode, not
687  use nil for MODE (and place the call on a hook) to avoid subtle problems  for modes derived from C mode.  To add them for derived modes too,
688  due to details of the implementation.  pass nil for MODE and add the call to c-mode-hook.
689    
690    For example:
691    
692     (add-hook 'c-mode-hook
693      (lambda ()
694       (font-lock-add-keywords 'c-mode
695        '((\"\\\\\\=<\\\\(FIXME\\\\):\" 1 font-lock-warning-face prepend)
696          (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" .
697           font-lock-keyword-face)))))
698    
699    The above procedure may fail to add keywords to derived modes if
700    some involved major mode does not follow the standard conventions.
701    File a bug report if this happens, so the major mode can be corrected.
702    
703  Note that some modes have specialized support for additional patterns, e.g.,  Note that some modes have specialized support for additional patterns, e.g.,
704  see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types',  see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types',
# Line 704  see the variables `c-font-lock-extra-typ Line 717  see the variables `c-font-lock-extra-typ
717           (font-lock-update-removed-keyword-alist mode keywords append))           (font-lock-update-removed-keyword-alist mode keywords append))
718          (t          (t
719           ;; Otherwise set or add the keywords now.           ;; Otherwise set or add the keywords now.
720           ;; This is a no-op if it has been done already in this buffer.           ;; This is a no-op if it has been done already in this buffer
721             ;; for the correct major mode.
722           (font-lock-set-defaults)           (font-lock-set-defaults)
723           (let ((was-compiled (eq (car font-lock-keywords) t)))           (let ((was-compiled (eq (car font-lock-keywords) t)))
724             ;; Bring back the user-level (uncompiled) keywords.             ;; Bring back the user-level (uncompiled) keywords.
# Line 774  see the variables `c-font-lock-extra-typ Line 788  see the variables `c-font-lock-extra-typ
788  MODE should be a symbol, the major mode command name, such as `c-mode'  MODE should be a symbol, the major mode command name, such as `c-mode'
789  or nil.  If nil, highlighting keywords are removed for the current buffer.  or nil.  If nil, highlighting keywords are removed for the current buffer.
790    
791  When used from a Lisp program (such as a minor mode), it is recommended to  To make the removal apply to modes derived from MODE as well,
792  use nil for MODE (and place the call on a hook) to avoid subtle problems  pass nil for MODE and add the call to MODE-hook.  This may fail
793  due to details of the implementation."  for some derived modes if some involved major mode does not
794    follow the standard conventions.  File a bug report if this
795    happens, so the major mode can be corrected."
796    (cond (mode    (cond (mode
797           ;; Remove one keyword at the time.           ;; Remove one keyword at the time.
798           (dolist (keyword keywords)           (dolist (keyword keywords)
# Line 1571  A LEVEL of nil is equal to a LEVEL of 0, Line 1587  A LEVEL of nil is equal to a LEVEL of 0,
1587    
1588  (defvar font-lock-set-defaults nil)     ; Whether we have set up defaults.  (defvar font-lock-set-defaults nil)     ; Whether we have set up defaults.
1589    
1590    (defvar font-lock-mode-major-mode)
1591  (defun font-lock-set-defaults ()  (defun font-lock-set-defaults ()
1592    "Set fontification defaults appropriately for this mode.    "Set fontification defaults appropriately for this mode.
1593  Sets various variables using `font-lock-defaults' (or, if nil, using  Sets various variables using `font-lock-defaults' (or, if nil, using
1594  `font-lock-defaults-alist') and `font-lock-maximum-decoration'."  `font-lock-defaults-alist') and `font-lock-maximum-decoration'."
1595    ;; Set fontification defaults iff not previously set.    ;; Set fontification defaults iff not previously set for correct major mode.
1596    (unless font-lock-set-defaults    (unless (and font-lock-set-defaults
1597                   (eq font-lock-mode-major-mode major-mode))
1598      (set (make-local-variable 'font-lock-set-defaults) t)      (set (make-local-variable 'font-lock-set-defaults) t)
1599      (make-local-variable 'font-lock-fontified)      (make-local-variable 'font-lock-fontified)
1600      (make-local-variable 'font-lock-multiline)      (make-local-variable 'font-lock-multiline)

Legend:
Removed from v.1.259  
changed lines
  Added in v.1.260

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26