Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / font-lock.el
index f820125..b7b617f 100644 (file)
@@ -1,18 +1,20 @@
 ;;; font-lock.el --- Electric font lock mode
 
-;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+;; Copyright (C) 1992-2011  Free Software Foundation, Inc.
 
-;; Author: jwz, then rms, then sm
+;; Author: Jamie Zawinski
+;;     Richard Stallman
+;;     Stefan Monnier
 ;; Maintainer: FSF
 ;; Keywords: languages, faces
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +22,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;; Modes that support Font Lock mode do so by defining one or more variables
 ;; whose values specify the fontification.  Font Lock mode knows of these
-;; variable names from (a) the buffer local variable `font-lock-defaults', if
-;; non-nil, or (b) the global variable `font-lock-defaults-alist', if the major
-;; mode has an entry.  (Font Lock mode is set up via (a) where a mode's
-;; patterns are distributed with the mode's package library, and (b) where a
-;; mode's patterns are distributed with font-lock.el itself.  An example of (a)
+;; variable names from the buffer local variable `font-lock-defaults'.
+;; (Font Lock mode is set up via (a) where a mode's patterns are
+;; distributed with the mode's package library, and (b) where a mode's
+;; patterns are distributed with font-lock.el itself.  An example of (a)
 ;; is Pascal mode, an example of (b) is Lisp mode.  Normally, the mechanism is
 ;; (a); (b) is used where it is not clear which package library should contain
 ;; the pattern definitions.)  Font Lock mode chooses which variable to use for
 ;; fontification based on `font-lock-maximum-decoration'.
 ;;
-;; Font Lock mode fontification behaviour can be modified in a number of ways.
+;; Font Lock mode fontification behavior can be modified in a number of ways.
 ;; See the below comments and the comments distributed throughout this file.
 
 ;;; Constructing patterns:
 ;;   i.e., (b) above, all modes that have items that can be thought of as, say,
 ;;   keywords, should be highlighted with the same face, etc.
 ;; - Make the face attributes fit the concept as far as possible.
-;;   i.e., function names might be a bold colour such as blue, comments might
-;;   be a bright colour such as red, character strings might be brown, because,
+;;   i.e., function names might be a bold color such as blue, comments might
+;;   be a bright color such as red, character strings might be brown, because,
 ;;   err, strings are brown (that was not the reason, please believe me).
 ;; - Don't use a non-nil OVERRIDE unless you have a good reason.
 ;;   Only use OVERRIDE for special things that are easy to define, such as the
 ;;; Code:
 
 (require 'syntax)
+(eval-when-compile (require 'cl))
 
 ;; Define core `font-lock' group.
 (defgroup font-lock '((jit-lock custom-group))
 ;; User variables.
 
 (defcustom font-lock-maximum-size 256000
-  "*Maximum size of a buffer for buffer fontification.
+  "Maximum size of a buffer for buffer fontification.
 Only buffers less than this can be fontified when Font Lock mode is turned on.
 If nil, means size is irrelevant.
 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
@@ -250,7 +250,7 @@ for buffers in Rmail mode, and size is irrelevant otherwise."
   :group 'font-lock)
 
 (defcustom font-lock-maximum-decoration t
-  "*Maximum decoration level for fontification.
+  "Maximum decoration level for fontification.
 If nil, use the default decoration (typically the minimum available).
 If t, use the maximum decoration available.
 If a number, use that level of decoration (or if not available the maximum).
@@ -274,13 +274,14 @@ decoration for buffers in C++ mode, and level 1 decoration otherwise."
                                      (integer :tag "level" 1)))))
   :group 'font-lock)
 
-(defcustom font-lock-verbose 0
-  "*If non-nil, means show status messages for buffer fontification.
+(defcustom font-lock-verbose nil
+  "If non-nil, means show status messages for buffer fontification.
 If a number, only buffers greater than this size have fontification messages."
   :type '(choice (const :tag "never" nil)
                 (other :tag "always" t)
                 (integer :tag "size"))
-  :group 'font-lock)
+  :group 'font-lock
+  :version "24.1")
 \f
 
 ;; Originally these variable values were face names such as `bold' etc.
@@ -289,6 +290,11 @@ If a number, only buffers greater than this size have fontification messages."
 ;; We now allow a FACENAME in `font-lock-keywords' to be any expression that
 ;; returns a face.  So the easiest thing is to continue using these variables,
 ;; rather than sometimes evaling FACENAME and sometimes not.  sm.
+
+;; Note that in new code, in the vast majority of cases there is no
+;; need to create variables that specify face names.  Simply using
+;; faces directly is enough.  Font-lock is not a template to be
+;; followed in this area.
 (defvar font-lock-comment-face         'font-lock-comment-face
   "Face name to use for comments.")
 
@@ -330,7 +336,7 @@ This can be an \"!\" or the \"n\" in \"ifndef\".")
   "Face name to use for preprocessor directives.")
 
 (defvar font-lock-reference-face       'font-lock-constant-face)
-(make-obsolete-variable 'font-lock-reference-face 'font-lock-constant-face)
+(make-obsolete-variable 'font-lock-reference-face 'font-lock-constant-face "20.3")
 
 ;; Fontification variables:
 
@@ -486,7 +492,8 @@ This is normally set via `font-lock-defaults'.")
 
 (defvar font-lock-keywords-case-fold-search nil
   "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
-This is normally set via `font-lock-defaults'.")
+This is set via the function `font-lock-set-defaults', based on
+the CASE-FOLD argument of `font-lock-defaults'.")
 (make-variable-buffer-local 'font-lock-keywords-case-fold-search)
 
 (defvar font-lock-syntactically-fontified 0
@@ -535,6 +542,8 @@ and what they do:
  contexts will not be affected.
 
 This is normally set via `font-lock-defaults'.")
+(make-obsolete-variable 'font-lock-syntactic-keywords
+                        'syntax-propertize-function "24.1")
 
 (defvar font-lock-syntax-table nil
   "Non-nil means use this syntax table for fontifying.
@@ -553,6 +562,8 @@ outside of any comment, string, or sexp.  This variable is semi-obsolete;
 we recommend setting `syntax-begin-function' instead.
 
 This is normally set via `font-lock-defaults'.")
+(make-obsolete-variable 'font-lock-beginning-of-syntax-function
+                        'syntax-begin-function "23.3")
 
 (defvar font-lock-mark-block-function nil
   "*Non-nil means use this function to mark a block of text.
@@ -603,23 +614,12 @@ Major/minor modes can set this variable if they know which option applies.")
   ;;
   ;; Borrowed from lazy-lock.el.
   ;; We use this to preserve or protect things when modifying text properties.
-  (defmacro save-buffer-state (varlist &rest body)
+  (defmacro save-buffer-state (&rest body)
     "Bind variables according to VARLIST and eval BODY restoring buffer state."
-    (declare (indent 1) (debug let))
-    (let ((modified (make-symbol "modified")))
-      `(let* ,(append varlist
-                     `((,modified (buffer-modified-p))
-                       (buffer-undo-list t)
-                       (inhibit-read-only t)
-                       (inhibit-point-motion-hooks t)
-                       (inhibit-modification-hooks t)
-                       deactivate-mark
-                       buffer-file-name
-                       buffer-file-truename))
-        (progn
-          ,@body)
-        (unless ,modified
-          (restore-buffer-modified-p nil)))))
+    (declare (indent 0) (debug t))
+    `(let ((inhibit-point-motion-hooks t))
+       (with-silent-modifications
+         ,@body)))
   ;;
   ;; Shut up the byte compiler.
   (defvar font-lock-face-attributes))  ; Obsolete but respected if set.
@@ -845,7 +845,7 @@ happens, so the major mode can be corrected."
 ;; themselves.
 
 (defcustom font-lock-support-mode 'jit-lock-mode
-  "*Support mode for Font Lock mode.
+  "Support mode for Font Lock mode.
 Support modes speed up Font Lock mode by being choosy about when fontification
 occurs.  The default support mode, Just-in-time Lock mode (symbol
 `jit-lock-mode'), is recommended.
@@ -886,49 +886,54 @@ The value of this variable is used when Font Lock mode is turned on."
 (defvar lazy-lock-mode)
 (defvar jit-lock-mode)
 
+(declare-function fast-lock-after-fontify-buffer "fast-lock")
+(declare-function fast-lock-after-unfontify-buffer "fast-lock")
+(declare-function fast-lock-mode "fast-lock")
+(declare-function lazy-lock-after-fontify-buffer "lazy-lock")
+(declare-function lazy-lock-after-unfontify-buffer "lazy-lock")
+(declare-function lazy-lock-mode "lazy-lock")
+
 (defun font-lock-turn-on-thing-lock ()
-  (let ((thing-mode (font-lock-value-in-major-mode font-lock-support-mode)))
-    (cond ((eq thing-mode 'fast-lock-mode)
-          (fast-lock-mode t))
-         ((eq thing-mode 'lazy-lock-mode)
-          (lazy-lock-mode t))
-         ((eq thing-mode 'jit-lock-mode)
-          ;; Prepare for jit-lock
-          (remove-hook 'after-change-functions
-                       'font-lock-after-change-function t)
-          (set (make-local-variable 'font-lock-fontify-buffer-function)
-               'jit-lock-refontify)
-          ;; Don't fontify eagerly (and don't abort if the buffer is large).
-          (set (make-local-variable 'font-lock-fontified) t)
-          ;; Use jit-lock.
-          (jit-lock-register 'font-lock-fontify-region
-                             (not font-lock-keywords-only))
-           ;; Tell jit-lock how we extend the region to refontify.
-           (add-hook 'jit-lock-after-change-extend-region-functions
-                     'font-lock-extend-jit-lock-region-after-change
-                     nil t)))))
+  (case (font-lock-value-in-major-mode font-lock-support-mode)
+    (fast-lock-mode (fast-lock-mode t))
+    (lazy-lock-mode (lazy-lock-mode t))
+    (jit-lock-mode
+     ;; Prepare for jit-lock
+     (remove-hook 'after-change-functions
+                  'font-lock-after-change-function t)
+     (set (make-local-variable 'font-lock-fontify-buffer-function)
+          'jit-lock-refontify)
+     ;; Don't fontify eagerly (and don't abort if the buffer is large).
+     (set (make-local-variable 'font-lock-fontified) t)
+     ;; Use jit-lock.
+     (jit-lock-register 'font-lock-fontify-region
+                        (not font-lock-keywords-only))
+     ;; Tell jit-lock how we extend the region to refontify.
+     (add-hook 'jit-lock-after-change-extend-region-functions
+               'font-lock-extend-jit-lock-region-after-change
+               nil t))))
 
 (defun font-lock-turn-off-thing-lock ()
-  (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
+  (cond ((bound-and-true-p fast-lock-mode)
         (fast-lock-mode -1))
-       ((and (boundp 'jit-lock-mode) jit-lock-mode)
+       ((bound-and-true-p jit-lock-mode)
         (jit-lock-unregister 'font-lock-fontify-region)
         ;; Reset local vars to the non-jit-lock case.
         (kill-local-variable 'font-lock-fontify-buffer-function))
-       ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
+       ((bound-and-true-p lazy-lock-mode)
         (lazy-lock-mode -1))))
 
 (defun font-lock-after-fontify-buffer ()
-  (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
+  (cond ((bound-and-true-p fast-lock-mode)
         (fast-lock-after-fontify-buffer))
        ;; Useless now that jit-lock intercepts font-lock-fontify-buffer.  -sm
        ;; (jit-lock-mode
        ;;  (jit-lock-after-fontify-buffer))
-       ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
+       ((bound-and-true-p lazy-lock-mode)
         (lazy-lock-after-fontify-buffer))))
 
 (defun font-lock-after-unfontify-buffer ()
-  (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
+  (cond ((bound-and-true-p fast-lock-mode)
         (fast-lock-after-unfontify-buffer))
        ;; Useless as well.  It's only called when:
        ;; - turning off font-lock: it does not matter if we leave spurious
@@ -938,7 +943,7 @@ The value of this variable is used when Font Lock mode is turned on."
        ;;
        ;; (jit-lock-mode
        ;;  (jit-lock-after-unfontify-buffer))
-       ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
+       ((bound-and-true-p lazy-lock-mode)
         (lazy-lock-after-unfontify-buffer))))
 
 ;;; End of Font Lock Support mode.
@@ -998,12 +1003,14 @@ and end buffer positions \(in that order) of the region to refontify, or nil
 \(which directs the caller to fontify a default region).
 This function should preserve the match-data.
 The region it returns may start or end in the middle of a line.")
+(make-variable-buffer-local 'font-lock-extend-after-change-region-function)
 
 (defun font-lock-fontify-buffer ()
   "Fontify the current buffer the way the function `font-lock-mode' would."
   (interactive)
   (font-lock-set-defaults)
-  (let ((font-lock-verbose (or font-lock-verbose (interactive-p))))
+  (let ((font-lock-verbose (or font-lock-verbose
+                              (called-interactively-p 'interactive))))
     (funcall font-lock-fontify-buffer-function)))
 
 (defun font-lock-unfontify-buffer ()
@@ -1014,7 +1021,7 @@ The region it returns may start or end in the middle of a line.")
   (funcall font-lock-fontify-region-function beg end loudly))
 
 (defun font-lock-unfontify-region (beg end)
-  (save-buffer-state nil
+  (save-buffer-state
     (funcall font-lock-unfontify-region-function beg end)))
 
 (defun font-lock-default-fontify-buffer ()
@@ -1107,39 +1114,38 @@ Put first the functions more likely to cause a change and cheaper to compute.")
 
 (defun font-lock-default-fontify-region (beg end loudly)
   (save-buffer-state
-      ((parse-sexp-lookup-properties
-        (or parse-sexp-lookup-properties font-lock-syntactic-keywords))
-       (old-syntax-table (syntax-table)))
-    (unwind-protect
-       (save-restriction
-         (unless font-lock-dont-widen (widen))
-         ;; Use the fontification syntax table, if any.
-         (when font-lock-syntax-table
-           (set-syntax-table font-lock-syntax-table))
-          ;; Extend the region to fontify so that it starts and ends at
-          ;; safe places.
-          (let ((funs font-lock-extend-region-functions)
-                (font-lock-beg beg)
-                (font-lock-end end))
-            (while funs
-              (setq funs (if (or (not (funcall (car funs)))
-                                 (eq funs font-lock-extend-region-functions))
-                             (cdr funs)
-                           ;; If there's been a change, we should go through
-                           ;; the list again since this new position may
-                           ;; warrant a different answer from one of the fun
-                           ;; we've already seen.
-                           font-lock-extend-region-functions)))
-            (setq beg font-lock-beg end font-lock-end))
-         ;; Now do the fontification.
-         (font-lock-unfontify-region beg end)
-         (when font-lock-syntactic-keywords
-           (font-lock-fontify-syntactic-keywords-region beg end))
-         (unless font-lock-keywords-only
-           (font-lock-fontify-syntactically-region beg end loudly))
-         (font-lock-fontify-keywords-region beg end loudly))
-      ;; Clean up.
-      (set-syntax-table old-syntax-table))))
+    ;; Use the fontification syntax table, if any.
+    (with-syntax-table (or font-lock-syntax-table (syntax-table))
+      (save-restriction
+        (unless font-lock-dont-widen (widen))
+        ;; Extend the region to fontify so that it starts and ends at
+        ;; safe places.
+        (let ((funs font-lock-extend-region-functions)
+              (font-lock-beg beg)
+              (font-lock-end end))
+          (while funs
+            (setq funs (if (or (not (funcall (car funs)))
+                               (eq funs font-lock-extend-region-functions))
+                           (cdr funs)
+                         ;; If there's been a change, we should go through
+                         ;; the list again since this new position may
+                         ;; warrant a different answer from one of the fun
+                         ;; we've already seen.
+                         font-lock-extend-region-functions)))
+          (setq beg font-lock-beg end font-lock-end))
+        ;; Now do the fontification.
+        (font-lock-unfontify-region beg end)
+        (when (and font-lock-syntactic-keywords
+                   (null syntax-propertize-function))
+          ;; Ensure the beginning of the file is properly syntactic-fontified.
+          (let ((start beg))
+            (when (< font-lock-syntactically-fontified start)
+              (setq start (max font-lock-syntactically-fontified (point-min)))
+              (setq font-lock-syntactically-fontified end))
+            (font-lock-fontify-syntactic-keywords-region start end)))
+        (unless font-lock-keywords-only
+          (font-lock-fontify-syntactically-region beg end loudly))
+        (font-lock-fontify-keywords-region beg end loudly)))))
 
 ;; The following must be rethought, since keywords can override fontification.
 ;;    ;; Now scan for keywords, but not if we are inside a comment now.
@@ -1272,10 +1278,6 @@ delimit the region to fontify."
              (font-lock-fontify-region (point) (mark)))
          ((error quit) (message "Fontifying block...%s" error-data)))))))
 
-(unless (featurep 'facemenu)
-  (error "facemenu must be loaded before font-lock"))
-(define-key facemenu-keymap "\M-o" 'font-lock-fontify-block)
-
 ;;; End of Fontification functions.
 \f
 ;;; Additional text property functions.
@@ -1295,6 +1297,12 @@ Optional argument OBJECT is the string or buffer containing the text."
     (while (/= start end)
       (setq next (next-single-property-change start prop object end)
            prev (get-text-property start prop object))
+      ;; Canonicalize old forms of face property.
+      (and (memq prop '(face font-lock-face))
+          (listp prev)
+          (or (keywordp (car prev))
+              (memq (car prev) '(foreground-color background-color)))
+          (setq prev (list prev)))
       (put-text-property start next prop
                         (append val (if (listp prev) prev (list prev)))
                         object)
@@ -1309,6 +1317,12 @@ Optional argument OBJECT is the string or buffer containing the text."
     (while (/= start end)
       (setq next (next-single-property-change start prop object end)
            prev (get-text-property start prop object))
+      ;; Canonicalize old forms of face property.
+      (and (memq prop '(face font-lock-face))
+          (listp prev)
+          (or (keywordp (car prev))
+              (memq (car prev) '(foreground-color background-color)))
+          (setq prev (list prev)))
       (put-text-property start next prop
                         (append (if (listp prev) prev (list prev)) val)
                         object)
@@ -1427,11 +1441,10 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM."
 (defun font-lock-fontify-syntactic-keywords-region (start end)
   "Fontify according to `font-lock-syntactic-keywords' between START and END.
 START should be at the beginning of a line."
-  ;; Ensure the beginning of the file is properly syntactic-fontified.
-  (when (and font-lock-syntactically-fontified
-            (< font-lock-syntactically-fontified start))
-    (setq start (max font-lock-syntactically-fontified (point-min)))
-    (setq font-lock-syntactically-fontified end))
+  (unless parse-sexp-lookup-properties
+    ;; We wouldn't go through so much trouble if we didn't intend to use those
+    ;; properties, would we?
+    (set (make-local-variable 'parse-sexp-lookup-properties) t))
   ;; If `font-lock-syntactic-keywords' is a symbol, get the real keywords.
   (when (symbolp font-lock-syntactic-keywords)
     (setq font-lock-syntactic-keywords (font-lock-eval-keywords
@@ -1449,9 +1462,10 @@ START should be at the beginning of a line."
       ;; Find an occurrence of `matcher' from `start' to `end'.
       (setq keyword (car keywords) matcher (car keyword))
       (goto-char start)
-      (while (if (stringp matcher)
-                (re-search-forward matcher end t)
-              (funcall matcher end))
+      (while (and (< (point) end)
+                  (if (stringp matcher)
+                      (re-search-forward matcher end t)
+                    (funcall matcher end)))
        ;; Apply each highlight to this instance of `matcher', which may be
        ;; specific highlights or more keywords anchored to `matcher'.
        (setq highlights (cdr keyword))
@@ -1473,19 +1487,18 @@ START should be at the beginning of a line."
 (defvar font-lock-comment-end-skip nil
   "If non-nil, Font Lock mode uses this instead of `comment-end'.")
 
-(defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)
+(defun font-lock-fontify-syntactically-region (start end &optional loudly)
   "Put proper face on each string and comment between START and END.
 START should be at the beginning of a line."
+  (syntax-propertize end)  ; Apply any needed syntax-table properties.
   (let ((comment-end-regexp
         (or font-lock-comment-end-skip
             (regexp-quote
              (replace-regexp-in-string "^ *" "" comment-end))))
-        state face beg)
+        ;; Find the `start' state.
+        (state (syntax-ppss start))
+        face beg)
     (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
-    (goto-char start)
-    ;;
-    ;; Find the `start' state.
-    (setq state (or ppss (syntax-ppss start)))
     ;;
     ;; Find each interesting place between here and `end'.
     (while
@@ -1741,22 +1754,38 @@ A LEVEL of nil is equal to a LEVEL of 0, a LEVEL of t is equal to
 
 (defvar font-lock-set-defaults nil)    ; Whether we have set up defaults.
 
-(defvar font-lock-mode-major-mode)
+(defun font-lock-refresh-defaults ()
+  "Restart fontification in current buffer after recomputing from defaults.
+Recompute fontification variables using `font-lock-defaults' and
+`font-lock-maximum-decoration'.  Then restart fontification.
+
+Use this function when you have changed any of the above
+variables directly.
+
+Note: This function will erase modifications done by
+`font-lock-add-keywords' or `font-lock-remove-keywords', but will
+preserve `hi-lock-mode' highlighting patterns."
+  (let ((hi-lock--inhibit-font-lock-hook t))
+    (font-lock-mode -1))
+  (kill-local-variable 'font-lock-set-defaults)
+  (font-lock-mode 1))
+
+(defvar font-lock-major-mode nil
+  "Major mode for which the font-lock settings have been setup.")
+(make-variable-buffer-local 'font-lock-major-mode)
+
 (defun font-lock-set-defaults ()
   "Set fontification defaults appropriately for this mode.
-Sets various variables using `font-lock-defaults' (or, if nil, using
-`font-lock-defaults-alist') and `font-lock-maximum-decoration'."
+Sets various variables using `font-lock-defaults' and
+`font-lock-maximum-decoration'."
   ;; Set fontification defaults if not previously set for correct major mode.
   (unless (and font-lock-set-defaults
-              (eq font-lock-mode-major-mode major-mode))
-    (setq font-lock-mode-major-mode major-mode)
+              (eq font-lock-major-mode major-mode))
+    (setq font-lock-major-mode major-mode)
     (set (make-local-variable 'font-lock-set-defaults) t)
     (make-local-variable 'font-lock-fontified)
     (make-local-variable 'font-lock-multiline)
-    (let* ((defaults (or font-lock-defaults
-                        (cdr (assq major-mode
-                                   (with-no-warnings
-                                      font-lock-defaults-alist)))))
+    (let* ((defaults font-lock-defaults)
           (keywords
            (font-lock-choose-keywords (nth 0 defaults)
                                       (font-lock-value-in-major-mode font-lock-maximum-decoration)))
@@ -1765,13 +1794,16 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
            (cdr-safe (assq major-mode font-lock-removed-keywords-alist))))
       (set (make-local-variable 'font-lock-defaults) defaults)
       ;; Syntactic fontification?
-      (when (nth 1 defaults)
-       (set (make-local-variable 'font-lock-keywords-only) t))
+      (if (nth 1 defaults)
+          (set (make-local-variable 'font-lock-keywords-only) t)
+        (kill-local-variable 'font-lock-keywords-only))
       ;; Case fold during regexp fontification?
-      (when (nth 2 defaults)
-       (set (make-local-variable 'font-lock-keywords-case-fold-search) t))
+      (if (nth 2 defaults)
+          (set (make-local-variable 'font-lock-keywords-case-fold-search) t)
+        (kill-local-variable 'font-lock-keywords-case-fold-search))
       ;; Syntax table for regexp and syntactic fontification?
-      (when (nth 3 defaults)
+      (if (null (nth 3 defaults))
+          (kill-local-variable 'font-lock-syntax-table)
        (set (make-local-variable 'font-lock-syntax-table)
             (copy-syntax-table (syntax-table)))
        (dolist (selem (nth 3 defaults))
@@ -1782,9 +1814,10 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
                            (mapcar 'identity (car selem))))
              (modify-syntax-entry char syntax font-lock-syntax-table)))))
       ;; Syntax function for syntactic fontification?
-      (when (nth 4 defaults)
+      (if (nth 4 defaults)
        (set (make-local-variable 'font-lock-beginning-of-syntax-function)
-            (nth 4 defaults)))
+               (nth 4 defaults))
+        (kill-local-variable 'font-lock-beginning-of-syntax-function))
       ;; Variable alist?
       (dolist (x (nthcdr 5 defaults))
        (set (make-local-variable (car x)) (cdr x)))
@@ -1804,7 +1837,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
        (setq font-lock-keywords
               (font-lock-compile-keywords font-lock-keywords))))))
 \f
-;;; Colour etc. support.
+;;; Color etc. support.
 
 ;; Note that `defface' will not overwrite any faces declared above via
 ;; `custom-declare-face'.
@@ -1822,7 +1855,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
     (((class color) (min-colors 16) (background dark))
      (:foreground "red1"))
     (((class color) (min-colors 8) (background light))
-     )
+     (:foreground "red"))
     (((class color) (min-colors 8) (background dark))
      )
     (t (:weight bold :slant italic)))
@@ -1843,7 +1876,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
 (defface font-lock-string-face
   '((((class grayscale) (background light)) (:foreground "DimGray" :slant italic))
     (((class grayscale) (background dark)) (:foreground "LightGray" :slant italic))
-    (((class color) (min-colors 88) (background light)) (:foreground "RosyBrown"))
+    (((class color) (min-colors 88) (background light)) (:foreground "VioletRed4"))
     (((class color) (min-colors 88) (background dark)) (:foreground "LightSalmon"))
     (((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
     (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
@@ -1872,7 +1905,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
 (defface font-lock-builtin-face
   '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold))
     (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold))
-    (((class color) (min-colors 88) (background light)) (:foreground "Orchid"))
+    (((class color) (min-colors 88) (background light)) (:foreground "MediumOrchid4"))
     (((class color) (min-colors 88) (background dark)) (:foreground "LightSteelBlue"))
     (((class color) (min-colors 16) (background light)) (:foreground "Orchid"))
     (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue"))
@@ -1896,7 +1929,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
      (:foreground "Gray90" :weight bold :slant italic))
     (((class grayscale) (background dark))
      (:foreground "DimGray" :weight bold :slant italic))
-    (((class color) (min-colors 88) (background light)) (:foreground "DarkGoldenrod"))
+    (((class color) (min-colors 88) (background light)) (:foreground "sienna"))
     (((class color) (min-colors 88) (background dark)) (:foreground "LightGoldenrod"))
     (((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
     (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
@@ -1922,7 +1955,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
      (:foreground "LightGray" :weight bold :underline t))
     (((class grayscale) (background dark))
      (:foreground "Gray50" :weight bold :underline t))
-    (((class color) (min-colors 88) (background light)) (:foreground "CadetBlue"))
+    (((class color) (min-colors 88) (background light)) (:foreground "dark cyan"))
     (((class color) (min-colors 88) (background dark)) (:foreground "Aquamarine"))
     (((class color) (min-colors 16) (background light)) (:foreground "CadetBlue"))
     (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
@@ -1961,7 +1994,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   "Font Lock mode face used to highlight grouping constructs in Lisp regexps."
   :group 'font-lock-faces)
 
-;;; End of Colour etc. support.
+;;; End of Color etc. support.
 \f
 ;;; Menu support.
 
@@ -2043,8 +2076,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
 ;;  ;; Activate less/more fontification entries if there are multiple levels for
 ;;  ;; the current buffer.  Sets `font-lock-fontify-level' to be of the form
 ;;  ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation.
-;;  (let ((keywords (or (nth 0 font-lock-defaults)
-;;                   (nth 1 (assq major-mode font-lock-defaults-alist))))
+;;  (let ((keywords (nth 0 font-lock-defaults))
 ;;     (level (font-lock-value-in-major-mode font-lock-maximum-decoration)))
 ;;    (make-local-variable 'font-lock-fontify-level)
 ;;    (if (or (symbolp keywords) (= (length keywords) 1))
@@ -2123,7 +2155,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
 ;; `cpp-font-lock-keywords' is handy for modes for the files.
 ;;
 ;; Here we cannot use `regexp-opt' because because regex-opt is not preloaded
-;; while font-lock.el is preloaded to emacs. So values pre-calculated with 
+;; while font-lock.el is preloaded to emacs. So values pre-calculated with
 ;; regexp-opt are used here.
 
 ;; `cpp-font-lock-keywords-source-directives' is calculated from:
@@ -2134,7 +2166,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
 ;;
 (defconst cpp-font-lock-keywords-source-directives
   "define\\|e\\(?:l\\(?:if\\|se\\)\\|ndif\\|rror\\)\\|file\\|i\\(?:f\\(?:n?def\\)?\\|mport\\|nclude\\)\\|line\\|pragma\\|undef\\|warning"
-  "Regular expressoin used in `cpp-font-lock-keywords'.")
+  "Regular expression used in `cpp-font-lock-keywords'.")
 
 ;; `cpp-font-lock-keywords-source-depth' is calculated from:
 ;;
@@ -2159,16 +2191,16 @@ Used in `cpp-font-lock-keywords'.")
        1 font-lock-string-face prepend)
      ;;
      ;; Fontify function macro names.
-     '("^#[ \t]*define[ \t]+\\([[:alpha:]_][[:alnum:]_$]*\\)(" 
+     '("^#[ \t]*define[ \t]+\\([[:alpha:]_][[:alnum:]_$]*\\)("
        (1 font-lock-function-name-face prepend)
        ;;
        ;; Macro arguments.
        ((lambda (limit)
          (re-search-forward
-          "\\(?:\\([[:alpha:]_][[:alnum:]_]*\\)[,]?\\)" 
-          (or (save-excursion (re-search-forward ")" limit t)) 
+          "\\(?:\\([[:alpha:]_][[:alnum:]_]*\\)[,]?\\)"
+          (or (save-excursion (re-search-forward ")" limit t))
               limit)
-          t)) 
+          t))
        nil nil (1 font-lock-variable-name-face prepend)))
      ;;
      ;; Fontify symbol names in #elif or #if ... defined preprocessor directives.
@@ -2183,10 +2215,10 @@ Used in `cpp-font-lock-keywords'.")
       '(1 font-lock-preprocessor-face prepend)
       (list (+ 2 directives-depth)
            'font-lock-variable-name-face nil t))))
-    "Font lock keyords for C preprocessor directives.
-`c-mode', `c++-mode' and `objc-mode' have their own 
-font lock keyords for C preprocessor directives. This definition is for the
-other modes in which C preprocessor directives are used. e.g. `asm-mode' and
+  "Font lock keywords for C preprocessor directives.
+`c-mode', `c++-mode' and `objc-mode' have their own font lock keywords
+for C preprocessor directives.  This definition is for the other modes
+in which C preprocessor directives are used. e.g. `asm-mode' and
 `ld-script-mode'.")
 
 \f
@@ -2216,8 +2248,9 @@ other modes in which C preprocessor directives are used. e.g. `asm-mode' and
                ((match-beginning 6) font-lock-variable-name-face)
                (t font-lock-type-face))
          nil t))
-      ;; Emacs Lisp autoload cookies.
-      ("^;;;###\\(autoload\\)" 1 font-lock-warning-face prepend)
+      ;; Emacs Lisp autoload cookies.  Supports the slightly different
+      ;; forms used by mh-e, calendar, etc.
+      ("^;;;###\\([-a-z]*autoload\\)" 1 font-lock-warning-face prepend)
       ;; Regexp negated char group.
       ("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend)))
   "Subdued level highlighting for Lisp modes.")
@@ -2231,16 +2264,19 @@ other modes in which C preprocessor directives are used. e.g. `asm-mode' and
               '("cond" "if" "while" "while-no-input" "let" "let*"
                 "prog" "progn" "progv" "prog1" "prog2" "prog*"
                 "inline" "lambda" "save-restriction" "save-excursion"
-                "save-window-excursion" "save-selected-window"
-                "save-match-data" "save-current-buffer" "unwind-protect"
-                "condition-case" "track-mouse"
-                "eval-after-load" "eval-and-compile" "eval-when-compile"
-                "eval-when" "eval-at-startup" "eval-next-after-load"
+                "save-selected-window" "save-window-excursion"
+                "save-match-data" "save-current-buffer"
+                "combine-after-change-calls" "unwind-protect"
+                "condition-case" "condition-case-no-debug"
+                "track-mouse" "eval-after-load" "eval-and-compile"
+                "eval-when-compile" "eval-when" "eval-next-after-load"
                 "with-case-table" "with-category-table"
-                "with-current-buffer" "with-electric-help"
+                "with-current-buffer" "with-demoted-errors"
+                "with-electric-help"
                 "with-local-quit" "with-no-warnings"
                 "with-output-to-string" "with-output-to-temp-buffer"
-                "with-selected-window" "with-selected-frame" "with-syntax-table"
+                "with-selected-window" "with-selected-frame"
+                "with-silent-modifications" "with-syntax-table"
                 "with-temp-buffer" "with-temp-file" "with-temp-message"
                 "with-timeout" "with-timeout-handler") t)
          "\\>")
@@ -2253,7 +2289,7 @@ other modes in which C preprocessor directives are used. e.g. `asm-mode' and
                 "restart-bind" "restart-case" "in-package"
                 "break" "ignore-errors"
                 "loop" "do" "do*" "dotimes" "dolist" "the" "locally"
-                "proclaim" "declaim" "declare" "symbol-macrolet"
+                "proclaim" "declaim" "declare" "symbol-macrolet" "letf"
                 "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
                 "destructuring-bind" "macrolet" "tagbody" "block" "go"
                 "multiple-value-bind" "multiple-value-prog1"
@@ -2310,5 +2346,4 @@ other modes in which C preprocessor directives are used. e.g. `asm-mode' and
 \f
 (provide 'font-lock)
 
-;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
 ;;; font-lock.el ends here