]> code.delx.au - gnu-emacs/blobdiff - lisp/font-lock.el
(Finternal_show_cursor_p): Fix doc string.
[gnu-emacs] / lisp / font-lock.el
index 7dbe8d08d9cf15c41cf34f86c0aae9d5fba5bd7a..9dcb8a3facb41dc019df962be783407ff912074a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; font-lock.el --- Electric font lock mode
 
 ;;; font-lock.el --- Electric font lock mode
 
-;; Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1999 Free Software Foundation, Inc.
 
 ;; Author: jwz, then rms, then sm <simon@gnu.org>
 ;; Maintainer: FSF
 
 ;; Author: jwz, then rms, then sm <simon@gnu.org>
 ;; Maintainer: FSF
 (defgroup font-lock nil
   "Font Lock mode text highlighting package."
   :link '(custom-manual "(emacs)Font Lock")
 (defgroup font-lock nil
   "Font Lock mode text highlighting package."
   :link '(custom-manual "(emacs)Font Lock")
+  :link '(custom-manual "(elisp)Font Lock Mode")
   :group 'faces)
 
 (defgroup font-lock-highlighting-faces nil
   :group 'faces)
 
 (defgroup font-lock-highlighting-faces nil
   :link '(custom-manual "(emacs)Support Modes")
   :load 'lazy-lock
   :group 'font-lock)
   :link '(custom-manual "(emacs)Support Modes")
   :load 'lazy-lock
   :group 'font-lock)
+
+(defgroup jit-lock nil
+  "Font Lock support mode to fontify just-in-time."
+  :link '(custom-manual "(emacs)Support Modes")
+  :version "21.1"
+  :load 'jit-lock
+  :group 'font-lock)
 \f
 ;; User variables.
 
 \f
 ;; User variables.
 
@@ -458,7 +466,7 @@ and those for buffer-specialised fontification functions,
        (java-mode-defaults
         '((java-font-lock-keywords java-font-lock-keywords-1
            java-font-lock-keywords-2 java-font-lock-keywords-3)
        (java-mode-defaults
         '((java-font-lock-keywords java-font-lock-keywords-1
            java-font-lock-keywords-2 java-font-lock-keywords-3)
-          nil nil ((?_ . "w") (?$ . "w") (?. . "w")) nil
+          nil nil ((?_ . "w") (?$ . "w")) nil
           (font-lock-mark-block-function . mark-defun)))
        (lisp-mode-defaults
         '((lisp-font-lock-keywords
           (font-lock-mark-block-function . mark-defun)))
        (lisp-mode-defaults
         '((lisp-font-lock-keywords
@@ -585,8 +593,8 @@ This is normally set via `font-lock-defaults'.")
 
 (defvar font-lock-inhibit-thing-lock nil
   "List of Font Lock mode related modes that should not be turned on.
 
 (defvar font-lock-inhibit-thing-lock nil
   "List of Font Lock mode related modes that should not be turned on.
-Currently, valid mode names as `fast-lock-mode' and `lazy-lock-mode'.
-This is normally set via `font-lock-defaults'.")
+Currently, valid mode names as `fast-lock-mode', `jit-lock-mode' and
+`lazy-lock-mode'.  This is normally set via `font-lock-defaults'.")
 
 (defvar font-lock-mode nil)            ; Whether we are turned on/modeline.
 (defvar font-lock-fontified nil)       ; Whether we have fontified the buffer.
 
 (defvar font-lock-mode nil)            ; Whether we are turned on/modeline.
 (defvar font-lock-fontified nil)       ; Whether we have fontified the buffer.
@@ -708,7 +716,7 @@ buffer local value for `font-lock-defaults', via its mode hook."
 (defun turn-on-font-lock ()
   "Turn on Font Lock mode conditionally.
 Turn on only if the terminal can display it."
 (defun turn-on-font-lock ()
   "Turn on Font Lock mode conditionally.
 Turn on only if the terminal can display it."
-  (when (and (not font-lock-mode) window-system)
+  (when (and (not font-lock-mode) (or window-system (tty-display-color-p)))
     (font-lock-mode)))
 
 ;;;###autoload
     (font-lock-mode)))
 
 ;;;###autoload
@@ -835,16 +843,19 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'."
       (message "Global Font Lock mode %s." (if on-p "enabled" "disabled")))
     (setq global-font-lock-mode on-p)))
 
       (message "Global Font Lock mode %s." (if on-p "enabled" "disabled")))
     (setq global-font-lock-mode on-p)))
 
-;; Naughty hack.  This variable was originally a `defvar' to keep track of
+;; This variable was originally a `defvar' to keep track of
 ;; whether Global Font Lock mode was turned on or not.  As a `defcustom' with
 ;; special `:set' and `:require' forms, we can provide custom mode control.
 ;; whether Global Font Lock mode was turned on or not.  As a `defcustom' with
 ;; special `:set' and `:require' forms, we can provide custom mode control.
+;;;###autoload
 (defcustom global-font-lock-mode nil
   "Toggle Global Font Lock mode.
 When Global Font Lock mode is enabled, Font Lock mode is automagically
 turned on in a buffer if its major mode is one of `font-lock-global-modes'.
 (defcustom global-font-lock-mode nil
   "Toggle Global Font Lock mode.
 When Global Font Lock mode is enabled, Font Lock mode is automagically
 turned on in a buffer if its major mode is one of `font-lock-global-modes'.
-You must modify via \\[customize] for this variable to have an effect."
+Setting this variable directly does not take effect;
+use either \\[customize] or the function `global-font-lock-mode'."
   :set (lambda (symbol value)
         (global-font-lock-mode (or value 0)))
   :set (lambda (symbol value)
         (global-font-lock-mode (or value 0)))
+  :initialize 'custom-initialize-default
   :type 'boolean
   :group 'font-lock
   :require 'font-lock)
   :type 'boolean
   :group 'font-lock
   :require 'font-lock)
@@ -910,11 +921,12 @@ means that Font Lock mode is turned on for buffers in C and C++ modes only."
 ;; `font-lock-after-fontify-buffer' and/or `font-lock-after-unfontify-buffer'
 ;; themselves.
 
 ;; `font-lock-after-fontify-buffer' and/or `font-lock-after-unfontify-buffer'
 ;; themselves.
 
-(defcustom font-lock-support-mode nil
+(defcustom font-lock-support-mode 'jit-lock-mode
   "*Support mode for Font Lock mode.
 Support modes speed up Font Lock mode by being choosy about when fontification
   "*Support mode for Font Lock mode.
 Support modes speed up Font Lock mode by being choosy about when fontification
-occurs.  Known support modes are Fast Lock mode (symbol `fast-lock-mode') and
-Lazy Lock mode (symbol `lazy-lock-mode').  See those modes for more info.
+occurs.  Known support modes are Fast Lock mode (symbol `fast-lock-mode'),
+Lazy Lock mode (symbol `lazy-lock-mode'), and Just-in-time Lock mode (symbol
+`jit-lock-mode'.  See those modes for more info.
 If nil, means support for Font Lock mode is never performed.
 If a symbol, use that support mode.
 If a list, each element should be of the form (MAJOR-MODE . SUPPORT-MODE),
 If nil, means support for Font Lock mode is never performed.
 If a symbol, use that support mode.
 If a list, each element should be of the form (MAJOR-MODE . SUPPORT-MODE),
@@ -927,6 +939,7 @@ The value of this variable is used when Font Lock mode is turned on."
   :type '(choice (const :tag "none" nil)
                 (const :tag "fast lock" fast-lock-mode)
                 (const :tag "lazy lock" lazy-lock-mode)
   :type '(choice (const :tag "none" nil)
                 (const :tag "fast lock" fast-lock-mode)
                 (const :tag "lazy lock" lazy-lock-mode)
+                (const :tag "jit lock" jit-lock-mode)
                 (repeat :menu-tag "mode specific" :tag "mode specific"
                         :value ((t . lazy-lock-mode))
                         (cons :tag "Instance"
                 (repeat :menu-tag "mode specific" :tag "mode specific"
                         :value ((t . lazy-lock-mode))
                         (cons :tag "Instance"
@@ -936,35 +949,45 @@ The value of this variable is used when Font Lock mode is turned on."
                               (radio :tag "Support"
                                      (const :tag "none" nil)
                                      (const :tag "fast lock" fast-lock-mode)
                               (radio :tag "Support"
                                      (const :tag "none" nil)
                                      (const :tag "fast lock" fast-lock-mode)
-                                     (const :tag "lazy lock" lazy-lock-mode)))
+                                     (const :tag "lazy lock" lazy-lock-mode)
+                                     (const :tag "JIT lock" jit-lock-mode)))
                         ))
   :group 'font-lock)
 
 (defvar fast-lock-mode nil)
 (defvar lazy-lock-mode nil)
                         ))
   :group 'font-lock)
 
 (defvar fast-lock-mode nil)
 (defvar lazy-lock-mode nil)
+(defvar jit-lock-mode nil)
 
 (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)
 
 (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)))))
+          (lazy-lock-mode t))
+         ((eq thing-mode 'jit-lock-mode)
+          (jit-lock-mode t)))))
 
 (defun font-lock-turn-off-thing-lock ()
   (cond (fast-lock-mode
         (fast-lock-mode nil))
 
 (defun font-lock-turn-off-thing-lock ()
   (cond (fast-lock-mode
         (fast-lock-mode nil))
+       (jit-lock-mode
+        (jit-lock-mode nil))
        (lazy-lock-mode
         (lazy-lock-mode nil))))
 
 (defun font-lock-after-fontify-buffer ()
   (cond (fast-lock-mode
         (fast-lock-after-fontify-buffer))
        (lazy-lock-mode
         (lazy-lock-mode nil))))
 
 (defun font-lock-after-fontify-buffer ()
   (cond (fast-lock-mode
         (fast-lock-after-fontify-buffer))
+       (jit-lock-mode
+        (jit-lock-after-fontify-buffer))
        (lazy-lock-mode
         (lazy-lock-after-fontify-buffer))))
 
 (defun font-lock-after-unfontify-buffer ()
   (cond (fast-lock-mode
         (fast-lock-after-unfontify-buffer))
        (lazy-lock-mode
         (lazy-lock-after-fontify-buffer))))
 
 (defun font-lock-after-unfontify-buffer ()
   (cond (fast-lock-mode
         (fast-lock-after-unfontify-buffer))
+       (jit-lock-mode
+        (jit-lock-after-unfontify-buffer))
        (lazy-lock-mode
         (lazy-lock-after-unfontify-buffer))))
 
        (lazy-lock-mode
         (lazy-lock-after-unfontify-buffer))))
 
@@ -1070,6 +1093,16 @@ The value of this variable is used when Font Lock mode is turned on."
          ;; Use the fontification syntax table, if any.
          (when font-lock-syntax-table
            (set-syntax-table font-lock-syntax-table))
          ;; Use the fontification syntax table, if any.
          (when font-lock-syntax-table
            (set-syntax-table font-lock-syntax-table))
+         ;; check to see if we should expand the beg/end area for
+         ;; proper multiline matches
+         (setq beg (if (get-text-property beg 'font-lock-multiline)
+                       (or (previous-single-property-change
+                            beg 'font-lock-multiline)
+                           (point-min))
+                     beg))
+         (setq end (or (text-property-any end (point-max)
+                                          'font-lock-multiline nil)
+                       (point-max)))
          ;; Now do the fontification.
          (font-lock-unfontify-region beg end)
          (when font-lock-syntactic-keywords
          ;; Now do the fontification.
          (font-lock-unfontify-region beg end)
          (when font-lock-syntactic-keywords
@@ -1090,9 +1123,10 @@ The value of this variable is used when Font Lock mode is turned on."
 
 (defun font-lock-default-unfontify-region (beg end)
   (save-buffer-state nil
 
 (defun font-lock-default-unfontify-region (beg end)
   (save-buffer-state nil
-    (if font-lock-syntactic-keywords
-       (remove-text-properties beg end '(face nil syntax-table nil))
-      (remove-text-properties beg end '(face nil)))))
+    (remove-text-properties beg end
+                           (if font-lock-syntactic-keywords
+                               '(face nil syntax-table nil font-lock-multiline nil)
+                             '(face nil font-lock-multiline nil)))))
 
 ;; Called when any modification is made to buffer text.
 (defun font-lock-after-change-function (beg end old-len)
 
 ;; Called when any modification is made to buffer text.
 (defun font-lock-after-change-function (beg end old-len)
@@ -1231,7 +1265,7 @@ see `font-lock-syntactic-keywords'."
         (start (match-beginning match)) (end (match-end match))
         (value (nth 1 highlight))
         (override (nth 2 highlight)))
         (start (match-beginning match)) (end (match-end match))
         (value (nth 1 highlight))
         (override (nth 2 highlight)))
-    (unless (numberp (car value))
+    (unless (numberp (car-safe value))
       (setq value (eval value)))
     (cond ((not start)
           ;; No match but we might not signal an error.
       (setq value (eval value)))
     (cond ((not start)
           ;; No match but we might not signal an error.
@@ -1402,12 +1436,16 @@ HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'."
 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
 LIMIT can be modified by the value of its PRE-MATCH-FORM."
   (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
 LIMIT can be modified by the value of its PRE-MATCH-FORM."
   (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
+       (lead-start (match-beginning 0))
        ;; Evaluate PRE-MATCH-FORM.
        (pre-match-value (eval (nth 1 keywords))))
     ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line.
        ;; Evaluate PRE-MATCH-FORM.
        (pre-match-value (eval (nth 1 keywords))))
     ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line.
-    (if (and (numberp pre-match-value) (> pre-match-value (point)))
-       (setq limit pre-match-value)
-      (save-excursion (end-of-line) (setq limit (point))))
+    (if (not (and (numberp pre-match-value) (> pre-match-value (point))))
+       (save-excursion (end-of-line) (setq limit (point)))
+      (setq limit pre-match-value)
+      (when (>= pre-match-value (save-excursion (forward-line 1) (point)))
+       ;; this is a multiline anchored match
+       (put-text-property (point) limit 'font-lock-multiline t)))
     (save-match-data
       ;; Find an occurrence of `matcher' before `limit'.
       (while (if (stringp matcher)
     (save-match-data
       ;; Find an occurrence of `matcher' before `limit'.
       (while (if (stringp matcher)
@@ -1439,9 +1477,17 @@ 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)
       ;; 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)))
+       (when (and (match-beginning 0)
+                  (>= (point)
+                      (save-excursion (goto-char (match-beginning 0))
+                                      (forward-line 1) (point))))
+         ;; this is a multiline regexp match
+         (put-text-property (match-beginning 0) (point)
+                            'font-lock-multiline t))
        ;; Apply each highlight to this instance of `matcher', which may be
        ;; specific highlights or more keywords anchored to `matcher'.
        (setq highlights (cdr keyword))
        ;; Apply each highlight to this instance of `matcher', which may be
        ;; specific highlights or more keywords anchored to `matcher'.
        (setq highlights (cdr keyword))
@@ -1553,8 +1599,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
                           (mapcar 'identity (car (car slist)))))
                  (syntax (cdr (car slist))))
              (while chars
                           (mapcar 'identity (car (car slist)))))
                  (syntax (cdr (car slist))))
              (while chars
-               (modify-syntax-entry (car chars) syntax
-                                    font-lock-syntax-table)
+               (modify-syntax-entry (car chars) syntax font-lock-syntax-table)
                (setq chars (cdr chars)))
              (setq slist (cdr slist))))))
       ;; Syntax function for syntactic fontification?
                (setq chars (cdr chars)))
              (setq slist (cdr slist))))))
       ;; Syntax function for syntactic fontification?
@@ -1655,7 +1700,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
 ;; But now we do it the custom way.  Note that `defface' will not overwrite any
 ;; faces declared above via `custom-declare-face'.
 (defface font-lock-comment-face
 ;; But now we do it the custom way.  Note that `defface' will not overwrite any
 ;; faces declared above via `custom-declare-face'.
 (defface font-lock-comment-face
-  '((((class grayscale) (background light))
+  '((((type tty) (class color)) (:foreground "red"))
+    (((class grayscale) (background light))
      (:foreground "DimGray" :bold t :italic t))
     (((class grayscale) (background dark))
      (:foreground "LightGray" :bold t :italic t))
      (:foreground "DimGray" :bold t :italic t))
     (((class grayscale) (background dark))
      (:foreground "LightGray" :bold t :italic t))
@@ -1666,7 +1712,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-string-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-string-face
-  '((((class grayscale) (background light)) (:foreground "DimGray" :italic t))
+  '((((type tty) (class color)) (:foreground "green"))
+    (((class grayscale) (background light)) (:foreground "DimGray" :italic t))
     (((class grayscale) (background dark)) (:foreground "LightGray" :italic t))
     (((class color) (background light)) (:foreground "RosyBrown"))
     (((class color) (background dark)) (:foreground "LightSalmon"))
     (((class grayscale) (background dark)) (:foreground "LightGray" :italic t))
     (((class color) (background light)) (:foreground "RosyBrown"))
     (((class color) (background dark)) (:foreground "LightSalmon"))
@@ -1675,7 +1722,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-keyword-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-keyword-face
-  '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
+  '((((type tty) (class color)) (:foreground "cyan" :weight bold))
+    (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "Purple"))
     (((class color) (background dark)) (:foreground "Cyan"))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "Purple"))
     (((class color) (background dark)) (:foreground "Cyan"))
@@ -1684,7 +1732,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-builtin-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-builtin-face
-  '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
+  '((((type tty) (class color)) (:foreground "blue" :weight light))
+    (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "Orchid"))
     (((class color) (background dark)) (:foreground "LightSteelBlue"))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "Orchid"))
     (((class color) (background dark)) (:foreground "LightSteelBlue"))
@@ -1693,14 +1742,16 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-function-name-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-function-name-face
-  '((((class color) (background light)) (:foreground "Blue"))
+  '((((type tty) (class color)) (:foreground "blue" :weight bold))
+    (((class color) (background light)) (:foreground "Blue"))
     (((class color) (background dark)) (:foreground "LightSkyBlue"))
     (t (:inverse-video t :bold t)))
   "Font Lock mode face used to highlight function names."
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-variable-name-face
     (((class color) (background dark)) (:foreground "LightSkyBlue"))
     (t (:inverse-video t :bold t)))
   "Font Lock mode face used to highlight function names."
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-variable-name-face
-  '((((class grayscale) (background light))
+  '((((type tty) (class color)) (:foreground "yellow" :weight light))
+    (((class grayscale) (background light))
      (:foreground "Gray90" :bold t :italic t))
     (((class grayscale) (background dark))
      (:foreground "DimGray" :bold t :italic t))
      (:foreground "Gray90" :bold t :italic t))
     (((class grayscale) (background dark))
      (:foreground "DimGray" :bold t :italic t))
@@ -1711,7 +1762,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-type-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-type-face
-  '((((class grayscale) (background light)) (:foreground "Gray90" :bold t))
+  '((((type tty) (class color)) (:foreground "green"))
+    (((class grayscale) (background light)) (:foreground "Gray90" :bold t))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "ForestGreen"))
     (((class color) (background dark)) (:foreground "PaleGreen"))
     (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
     (((class color) (background light)) (:foreground "ForestGreen"))
     (((class color) (background dark)) (:foreground "PaleGreen"))
@@ -1720,7 +1772,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-constant-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-constant-face
-  '((((class grayscale) (background light))
+  '((((type tty) (class color)) (:foreground "magenta"))
+    (((class grayscale) (background light))
      (:foreground "LightGray" :bold t :underline t))
     (((class grayscale) (background dark))
      (:foreground "Gray50" :bold t :underline t))
      (:foreground "LightGray" :bold t :underline t))
     (((class grayscale) (background dark))
      (:foreground "Gray50" :bold t :underline t))
@@ -1731,7 +1784,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-warning-face
   :group 'font-lock-highlighting-faces)
 
 (defface font-lock-warning-face
-  '((((class color) (background light)) (:foreground "Red" :bold t))
+  '((((type tty) (class color)) (:foreground "red"))
+    (((class color) (background light)) (:foreground "Red" :bold t))
     (((class color) (background dark)) (:foreground "Pink" :bold t))
     (t (:inverse-video t :bold t)))
   "Font Lock mode face used to highlight warnings."
     (((class color) (background dark)) (:foreground "Pink" :bold t))
     (t (:inverse-video t :bold t)))
   "Font Lock mode face used to highlight warnings."
@@ -1910,7 +1964,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
               nil t))
      ;;
      ;; Emacs Lisp autoload cookies.
               nil t))
      ;;
      ;; Emacs Lisp autoload cookies.
-     '("^;;;###\\(autoload\\)\\>" 1 font-lock-warning-face prepend)
+     '("^;;;###\\(autoload\\)" 1 font-lock-warning-face prepend)
      ))
   "Subdued level highlighting for Lisp modes.")
 
      ))
   "Subdued level highlighting for Lisp modes.")
 
@@ -1971,7 +2025,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
       '("\\<:\\sw\\sw+\\>" 0 font-lock-builtin-face)
       ;;
       ;; ELisp and CLisp `&' keywords as types.
       '("\\<:\\sw\\sw+\\>" 0 font-lock-builtin-face)
       ;;
       ;; ELisp and CLisp `&' keywords as types.
-      '("\\<\\&\\sw+\\>" . font-lock-type-face)
+      '("\\&\\sw+\\>" . font-lock-type-face)
       )))
   "Gaudy level highlighting for Lisp modes.")
 
       )))
   "Gaudy level highlighting for Lisp modes.")
 
@@ -2179,6 +2233,7 @@ The value of this variable is used when Font Lock mode is turned on."
     "map" "multimap"
     "hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?"
     "stack" "queue" "priority_queue"
     "map" "multimap"
     "hash\\(_\\(m\\(ap\\|ulti\\(map\\|set\\)\\)\\|set\\)\\)?"
     "stack" "queue" "priority_queue"
+    "type_info"
     "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator"
     "reference" "const_reference")
   "*List of extra types to fontify in C++ mode.
     "iterator" "const_iterator" "reverse_iterator" "const_reverse_iterator"
     "reference" "const_reference")
   "*List of extra types to fontify in C++ mode.
@@ -2200,10 +2255,11 @@ The value of this variable is used when Font Lock mode is turned on."
   :type 'font-lock-extra-types-widget
   :group 'font-lock-extra-types)
 
   :type 'font-lock-extra-types-widget
   :group 'font-lock-extra-types)
 
-(defcustom java-font-lock-extra-types '("[A-Z\300-\326\330-\337]\\sw+")
+(defcustom java-font-lock-extra-types
+  '("[A-Z\300-\326\330-\337]\\sw*[a-z]\\sw*")
   "*List of extra types to fontify in Java mode.
 Each list item should be a regexp not containing word-delimiters.
   "*List of extra types to fontify in Java mode.
 Each list item should be a regexp not containing word-delimiters.
-For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw+\") means capitalised
+For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw*[a-z]\\\\sw*\") means capitalised
 words (and words conforming to the Java id spec) are treated as type names.
 
 The value of this variable is used when Font Lock mode is turned on."
 words (and words conforming to the Java id spec) are treated as type names.
 
 The value of this variable is used when Font Lock mode is turned on."
@@ -2243,7 +2299,9 @@ See also `c-font-lock-extra-types'.")
                        "switch" "while" "sizeof"
                        ;; Type related, but we don't do anything special.
                        "typedef" "extern" "auto" "register" "static"
                        "switch" "while" "sizeof"
                        ;; Type related, but we don't do anything special.
                        "typedef" "extern" "auto" "register" "static"
-                       "volatile" "const") t)))
+                       "volatile" "const"
+                       ;; Dan Nicolaescu <done@gnu.org> says this is new.
+                       "restrict") t)))
        (c-type-specs
        (eval-when-compile
          (regexp-opt '("enum" "struct" "union") t)))
        (c-type-specs
        (eval-when-compile
          (regexp-opt '("enum" "struct" "union") t)))
@@ -2255,7 +2313,7 @@ See also `c-font-lock-extra-types'.")
           (,@ (eval-when-compile
                 (regexp-opt
                  '("char" "short" "int" "long" "signed" "unsigned"
           (,@ (eval-when-compile
                 (regexp-opt
                  '("char" "short" "int" "long" "signed" "unsigned"
-                   "float" "double" "void"))))
+                   "float" "double" "void" "complex"))))
           c-font-lock-extra-types)
          "\\|"))
        (c-type-names-depth
           c-font-lock-extra-types)
          "\\|"))
        (c-type-names-depth
@@ -2306,10 +2364,10 @@ See also `c-font-lock-extra-types'.")
     ;; Fontify case/goto keywords and targets, and case default/goto tags.
     '("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
       (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
     ;; Fontify case/goto keywords and targets, and case default/goto tags.
     '("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
       (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
-    ;; Anders Lindgren <andersl@csd.uu.se> points out that it is quicker to use
-    ;; MATCH-ANCHORED to effectively anchor the regexp on the left.
+    ;; Anders Lindgren <andersl@andersl.com> points out that it is quicker to
+    ;; use MATCH-ANCHORED to effectively anchor the regexp on the left.
     ;; This must come after the one for keywords and targets.
     ;; This must come after the one for keywords and targets.
-    '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:"
+    '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
           (beginning-of-line) (end-of-line)
           (1 font-lock-constant-face)))
     )))
           (beginning-of-line) (end-of-line)
           (1 font-lock-constant-face)))
     )))
@@ -2422,6 +2480,7 @@ See also `c++-font-lock-extra-types'.")
          (regexp-opt
           '("break" "continue" "do" "else" "for" "if" "return" "switch"
             "while" "asm" "catch" "delete" "new" "sizeof" "this" "throw" "try"
          (regexp-opt
           '("break" "continue" "do" "else" "for" "if" "return" "switch"
             "while" "asm" "catch" "delete" "new" "sizeof" "this" "throw" "try"
+            "typeid"
             ;; Branko Cibej <branko.cibej@hermes.si> says this is new.
             "export"
             ;; Mark Mitchell <mmitchell@usa.net> says these are new.
             ;; Branko Cibej <branko.cibej@hermes.si> says this is new.
             "export"
             ;; Mark Mitchell <mmitchell@usa.net> says these are new.
@@ -2541,8 +2600,10 @@ See also `c++-font-lock-extra-types'.")
                  ;; Fontify as a variable or function name.
                  '(1 (cond ((or (match-beginning 2) (match-beginning 4))
                             font-lock-type-face)
                  ;; Fontify as a variable or function name.
                  '(1 (cond ((or (match-beginning 2) (match-beginning 4))
                             font-lock-type-face)
-                           ((match-beginning 6) font-lock-function-name-face)
-                           (t font-lock-variable-name-face)))
+                           ((and (match-beginning 6) (c-at-toplevel-p))
+                            font-lock-function-name-face)
+                           (t
+                            font-lock-variable-name-face)))
                  '(3 font-lock-type-face nil t)
                  '(5 (if (match-beginning 6)
                          font-lock-function-name-face
                  '(3 font-lock-type-face nil t)
                  '(5 (if (match-beginning 6)
                          font-lock-function-name-face
@@ -2566,8 +2627,10 @@ See also `c++-font-lock-extra-types'.")
                  ;; Fontify as a variable or function name.
                  '(1 (cond ((or (match-beginning 2) (match-beginning 4))
                             font-lock-type-face)
                  ;; Fontify as a variable or function name.
                  '(1 (cond ((or (match-beginning 2) (match-beginning 4))
                             font-lock-type-face)
-                           ((match-beginning 6) font-lock-function-name-face)
-                           (t font-lock-variable-name-face)))
+                           ((and (match-beginning 6) (c-at-toplevel-p))
+                            font-lock-function-name-face)
+                           (t
+                            font-lock-variable-name-face)))
                  '(3 font-lock-type-face nil t)
                  '(5 (if (match-beginning 6)
                          font-lock-function-name-face
                  '(3 font-lock-type-face nil t)
                  '(5 (if (match-beginning 6)
                          font-lock-function-name-face
@@ -2771,79 +2834,75 @@ See also `java-font-lock-extra-types'.")
   "Gaudy level highlighting for Java mode.
 See also `java-font-lock-extra-types'.")
 
   "Gaudy level highlighting for Java mode.
 See also `java-font-lock-extra-types'.")
 
-;; Regexps written with help from Fred White <fwhite@bbn.com> and
-;; Anders Lindgren <andersl@csd.uu.se>.
+;; Regexps written with help from Fred White <fwhite@bbn.com>,
+;; Anders Lindgren <andersl@andersl.com> and Carl Manning <caroma@ai.mit.edu>.
 (let* ((java-keywords
        (eval-when-compile
          (regexp-opt
           '("catch" "do" "else" "super" "this" "finally" "for" "if"
 (let* ((java-keywords
        (eval-when-compile
          (regexp-opt
           '("catch" "do" "else" "super" "this" "finally" "for" "if"
-            ;; Anders Lindgren <andersl@csd.uu.se> says these have gone.
+            ;; Anders Lindgren <andersl@andersl.com> says these have gone.
             ;; "cast" "byvalue" "future" "generic" "operator" "var"
             ;; "inner" "outer" "rest"
             ;; "cast" "byvalue" "future" "generic" "operator" "var"
             ;; "inner" "outer" "rest"
+            "implements" "extends" "throws" "instanceof" "new"
             "interface" "return" "switch" "throw" "try" "while") t)))
        ;;
             "interface" "return" "switch" "throw" "try" "while") t)))
        ;;
-       ;; These are immediately followed by an object name.
-       (java-minor-types
-       (eval-when-compile
-         (regexp-opt '("boolean" "char" "byte" "short" "int" "long"
-                       "float" "double" "void"))))
+       ;; Classes immediately followed by an object name.
+       (java-type-names
+       `(mapconcat 'identity
+         (cons 
+          (,@ (eval-when-compile
+                (regexp-opt '("boolean" "char" "byte" "short" "int" "long"
+                              "float" "double" "void"))))
+          java-font-lock-extra-types)
+         "\\|"))
+       (java-type-names-depth `(regexp-opt-depth (,@ java-type-names)))
        ;;
        ;; These are eventually followed by an object name.
        ;;
        ;; These are eventually followed by an object name.
-       (java-major-types
+       (java-type-specs
        (eval-when-compile
          (regexp-opt
           '("abstract" "const" "final" "synchronized" "transient" "static"
        (eval-when-compile
          (regexp-opt
           '("abstract" "const" "final" "synchronized" "transient" "static"
-            ;; Anders Lindgren <andersl@csd.uu.se> says this has gone.
+            ;; Anders Lindgren <andersl@andersl.com> says this has gone.
             ;; "threadsafe"
             ;; "threadsafe"
-            "volatile" "public" "private" "protected" "native"))))
-       ;;
-       ;; Random types immediately followed by an object name.
-       (java-other-types
-       '(mapconcat 'identity (cons "\\sw+\\.\\sw+" java-font-lock-extra-types)
-                   "\\|"))
-       (java-other-depth
-       `(regexp-opt-depth (,@ java-other-types)))
+            "volatile" "public" "private" "protected" "native"
+            ;; Carl Manning <caroma@ai.mit.edu> says this is new.
+            "strictfp"))))
        )
  (setq java-font-lock-keywords-1
   (list
    ;;
    ;; Fontify class names.
    '("\\<\\(class\\)\\>[ \t]*\\(\\sw+\\)?"
        )
  (setq java-font-lock-keywords-1
   (list
    ;;
    ;; Fontify class names.
    '("\\<\\(class\\)\\>[ \t]*\\(\\sw+\\)?"
-     (1 font-lock-type-face) (2 font-lock-function-name-face nil t))
+     (1 font-lock-keyword-face) (2 font-lock-type-face nil t))
    ;;
    ;; Fontify package names in import directives.
    '("\\<\\(import\\|package\\)\\>[ \t]*\\(\\sw+\\)?"
    ;;
    ;; Fontify package names in import directives.
    '("\\<\\(import\\|package\\)\\>[ \t]*\\(\\sw+\\)?"
-     (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
+     (1 font-lock-keyword-face)
+     (2 font-lock-constant-face nil t)
+     ("\\=\\.\\(\\*\\|\\sw+\\)" nil nil
+      (1 font-lock-constant-face nil t)))
    ))
 
  (setq java-font-lock-keywords-2
   (append java-font-lock-keywords-1
    (list
     ;;
    ))
 
  (setq java-font-lock-keywords-2
   (append java-font-lock-keywords-1
    (list
     ;;
-    ;; Fontify all builtin type specifiers.
-    (cons (concat "\\<\\(" java-minor-types "\\)\\>") 'font-lock-type-face)
+    ;; Fontify class names.
+    `(eval .
+      (cons (concat "\\<\\(" (,@ java-type-names) "\\)\\>[^.]")
+           '(1 font-lock-type-face)))
     ;;
     ;; Fontify all builtin keywords (except below).
     ;;
     ;; Fontify all builtin keywords (except below).
-    (concat "\\<\\(" java-keywords "\\|" java-major-types "\\)\\>")
+    (concat "\\<\\(" java-keywords "\\|" java-type-specs "\\)\\>")
     ;;
     ;; Fontify keywords and targets, and case default/goto tags.
     (list "\\<\\(break\\|case\\|continue\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
          '(1 font-lock-keyword-face) '(2 font-lock-constant-face nil t))
     ;; This must come after the one for keywords and targets.
     ;;
     ;; Fontify keywords and targets, and case default/goto tags.
     (list "\\<\\(break\\|case\\|continue\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
          '(1 font-lock-keyword-face) '(2 font-lock-constant-face nil t))
     ;; This must come after the one for keywords and targets.
-    '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:"
+    '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
           (beginning-of-line) (end-of-line)
           (1 font-lock-constant-face)))
     ;;
           (beginning-of-line) (end-of-line)
           (1 font-lock-constant-face)))
     ;;
-    ;; Fontify keywords and types; the first can be followed by a type list.
-    (list (concat "\\<\\("
-                 "implements\\|throws\\|"
-                 "\\(extends\\|instanceof\\|new\\)"
-                 "\\)\\>[ \t]*\\(\\sw+\\)?")
-         '(1 font-lock-keyword-face) '(3 font-lock-type-face nil t)
-         '("\\=[ \t]*,[ \t]*\\(\\sw+\\)"
-           (if (match-beginning 2) (goto-char (match-end 2))) nil
-           (1 font-lock-type-face)))
-    ;;
     ;; Fontify all constants.
     '("\\<\\(false\\|null\\|true\\)\\>" . font-lock-constant-face)
     ;;
     ;; Fontify all constants.
     '("\\<\\(false\\|null\\|true\\)\\>" . font-lock-constant-face)
     ;;
@@ -2862,50 +2921,25 @@ See also `java-font-lock-extra-types'.")
    ;; We still have to fontify type specifiers individually, as Java is hairy.
    (list
     ;;
    ;; We still have to fontify type specifiers individually, as Java is hairy.
    (list
     ;;
-    ;; Fontify random types in casts.
-    `(eval .
-      (list (concat "(\\(" (,@ java-other-types) "\\))"
-                   "[ \t]*\\(\\sw\\|[\"\(]\\)")
-           ;; Fontify the type name.
-           '(1 font-lock-type-face)))
-    ;;
     ;; Fontify random types immediately followed by an item or items.
     `(eval .
     ;; Fontify random types immediately followed by an item or items.
     `(eval .
-      (list (concat "\\<\\(" (,@ java-other-types) "\\)\\>"
-                   "\\([ \t]*\\[[ \t]*\\]\\)*"
-                   "[ \t]*\\sw")
-           ;; Fontify the type name.
-           '(1 font-lock-type-face)))
-    `(eval .
-      (list (concat "\\<\\(" (,@ java-other-types) "\\)\\>"
+      (list (concat "\\<\\(" (,@ java-type-names) "\\)\\>"
                    "\\([ \t]*\\[[ \t]*\\]\\)*"
                    "\\([ \t]*\\sw\\)")
            ;; Fontify each declaration item.
            (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
                  ;; Start and finish with point after the type specifier.
                  (list 'goto-char (list 'match-beginning
                    "\\([ \t]*\\[[ \t]*\\]\\)*"
                    "\\([ \t]*\\sw\\)")
            ;; Fontify each declaration item.
            (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
                  ;; Start and finish with point after the type specifier.
                  (list 'goto-char (list 'match-beginning
-                                        (+ (,@ java-other-depth) 3)))
+                                        (+ (,@ java-type-names-depth) 3)))
                  (list 'goto-char (list 'match-beginning
                  (list 'goto-char (list 'match-beginning
-                                        (+ (,@ java-other-depth) 3)))
+                                        (+ (,@ java-type-names-depth) 3)))
                  ;; Fontify as a variable or function name.
                  '(1 (if (match-beginning 2)
                          font-lock-function-name-face
                        font-lock-variable-name-face)))))
     ;;
                  ;; Fontify as a variable or function name.
                  '(1 (if (match-beginning 2)
                          font-lock-function-name-face
                        font-lock-variable-name-face)))))
     ;;
-    ;; Fontify those that are immediately followed by an item or items.
-    (list (concat "\\<\\(" java-minor-types "\\)\\>"
-                 "\\([ \t]*\\[[ \t]*\\]\\)*")
-         ;; Fontify each declaration item.
-         '(font-lock-match-c-style-declaration-item-and-skip-to-next
-           ;; Start and finish with point after the type specifier.
-           nil (goto-char (match-end 0))
-           ;; Fontify as a variable or function name.
-           (1 (if (match-beginning 2)
-                  font-lock-function-name-face
-                font-lock-variable-name-face))))
-    ;;
     ;; Fontify those that are eventually followed by an item or items.
     ;; Fontify those that are eventually followed by an item or items.
-    (list (concat "\\<\\(" java-major-types "\\)\\>"
+    (list (concat "\\<\\(" java-type-specs "\\)\\>"
                  "\\([ \t]+\\sw+\\>"
                  "\\([ \t]*\\[[ \t]*\\]\\)*"
                  "\\)*")
                  "\\([ \t]+\\sw+\\>"
                  "\\([ \t]*\\[[ \t]*\\]\\)*"
                  "\\)*")