]> code.delx.au - gnu-emacs/blobdiff - lisp/font-lock.el
(describe-mode): Test mini-mode symbol for being
[gnu-emacs] / lisp / font-lock.el
index 1229a3e3cffb4daeae4f475bf1b0892667b41752..adaa514574a8ce55f3825de66c013895d76278c6 100644 (file)
@@ -1,9 +1,9 @@
 ;;; font-lock.el --- Electric font lock mode
 
-;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999
+;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000
 ;;  Free Software Foundation, Inc.
 
-;; Author: jwz, then rms, then sm <simon@gnu.org>
+;; Author: jwz, then rms, then sm
 ;; Maintainer: FSF
 ;; Keywords: languages, faces
 
 ;;
 ;; Efficient regexps for use as MATCHERs for `font-lock-keywords' and
 ;; `font-lock-syntactic-keywords' can be generated via the function
-;; `regexp-opt', and their depth counted via the function `regexp-opt-depth'.
+;; `regexp-opt'.
 
 ;;; Adding patterns for modes that already support Font Lock:
 
@@ -332,10 +332,10 @@ MATCH-HIGHLIGHT should be of the form:
 where MATCHER can be either the regexp to search for, or the function name to
 call to make the search (called with one argument, the limit of the search) and
 return non-nil if it succeeds (and set `match-data' appropriately).
-MATCHER regexps can be generated via the function `regexp-opt'.  MATCH is the
-subexpression of MATCHER to be highlighted.  MATCH can be calculated via the
-function `regexp-opt-depth'.  FACENAME is an expression whose value is the face
-name to use.  Face default attributes can be modified via \\[customize].
+MATCHER regexps can be generated via the function `regexp-opt'.  MATCH is
+the subexpression of MATCHER to be highlighted.  FACENAME is an expression
+whose value is the face name to use.  Face default attributes can be
+modified via \\[customize].
 
 OVERRIDE and LAXMATCH are flags.  If OVERRIDE is t, existing fontification can
 be overwritten.  If `keep', only parts not already fontified are highlighted.
@@ -532,9 +532,10 @@ the differences are listed below.  MATCH-HIGHLIGHT should be of the form:
 
  (MATCH SYNTAX OVERRIDE LAXMATCH)
 
-where SYNTAX can be of the form (SYNTAX-CODE . MATCHING-CHAR), the name of a
-syntax table, or an expression whose value is such a form or a syntax table.
-OVERRIDE cannot be `prepend' or `append'.
+where SYNTAX can be of the form (SYNTAX-CODE . MATCHING-CHAR) (see
+also `string-to-syntax'), the name of a syntax table, or an expression
+whose value is such a form or a syntax table.  OVERRIDE cannot be
+`prepend' or `append'.
 
 For example, an element of the form highlights syntactically:
 
@@ -638,6 +639,7 @@ Major/minor modes can set this variable if they know which option applies.")
         (when (and (not modified) (buffer-modified-p))
           (set-buffer-modified-p nil)))))
   (put 'save-buffer-state 'lisp-indent-function 1)
+  (def-edebug-spec save-buffer-state let)
   ;;
   ;; Shut up the byte compiler.
   (defvar global-font-lock-mode)       ; Now a defcustom.
@@ -952,10 +954,10 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'."
           (setq font-lock-buffers (buffer-list)))
          (t
           (remove-hook 'find-file-hooks 'turn-on-font-lock-if-enabled)
-          (mapcar (function (lambda (buffer)
-                              (with-current-buffer buffer
-                                (when font-lock-mode
-                                  (font-lock-mode)))))
+          (mapc (function (lambda (buffer)
+                            (with-current-buffer buffer
+                              (when font-lock-mode
+                                (font-lock-mode)))))
                   (buffer-list))))
     (when message
       (message "Global Font Lock mode %s." (if on-p "enabled" "disabled")))
@@ -1070,6 +1072,7 @@ The value of this variable is used when Font Lock mode is turned on."
                                      (const :tag "lazy lock" lazy-lock-mode)
                                      (const :tag "JIT lock" jit-lock-mode)))
                         ))
+  :version "21.1"
   :group 'font-lock)
 
 (defvar fast-lock-mode nil)
@@ -1096,16 +1099,23 @@ The value of this variable is used when Font Lock mode is turned on."
 (defun font-lock-after-fontify-buffer ()
   (cond (fast-lock-mode
         (fast-lock-after-fontify-buffer))
-       (jit-lock-mode
-        (jit-lock-after-fontify-buffer))
+       ;; Useless now that jit-lock intercepts font-lock-fontify-buffer.  -sm
+       ;; (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))
-       (jit-lock-mode
-        (jit-lock-after-unfontify-buffer))
+       ;; Useless as well.  It's only called when:
+       ;; - turning off font-lock: it does not matter if we leave spurious
+       ;;   `fontified' text props around since jit-lock-mode is also off.
+       ;; - font-lock-default-fontify-buffer fails: this is not run
+       ;;   any more anyway.   -sm
+       ;; 
+       ;; (jit-lock-mode
+       ;;  (jit-lock-after-unfontify-buffer))
        (lazy-lock-mode
         (lazy-lock-after-unfontify-buffer))))
 
@@ -1390,8 +1400,10 @@ see `font-lock-syntactic-keywords'."
         (start (match-beginning match)) (end (match-end match))
         (value (nth 1 highlight))
         (override (nth 2 highlight)))
-    (unless (numberp (car-safe value))
-      (setq value (eval value)))
+    (cond ((stringp value)
+          (setq value (string-to-syntax value)))
+         ((not (numberp (car-safe value)))
+          (setq value (eval value))))
     (cond ((not start)
           ;; No match but we might not signal an error.
           (or (nth 3 highlight)
@@ -1571,15 +1583,16 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM."
       (when (and font-lock-multiline
                 (funcall (if (eq font-lock-multiline t) '>= '>)
                          pre-match-value
-                         (save-excursion (forward-line 1) (point))))
+                         (line-beginning-position 2)))
        ;; this is a multiline anchored match
        (setq font-lock-multiline t)
        (put-text-property (point) limit 'font-lock-multiline t)))
     (save-match-data
       ;; Find an occurrence of `matcher' before `limit'.
-      (while (if (stringp matcher)
-                (re-search-forward matcher limit t)
-              (funcall matcher limit))
+      (while (and (< (point) limit)
+                 (if (stringp matcher)
+                     (re-search-forward matcher limit t)
+                   (funcall matcher limit)))
        ;; Apply each highlight to this instance of `matcher'.
        (setq highlights lowdarks)
        (while highlights
@@ -2084,9 +2097,9 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
                   ;; Function declarations.
                   "\\(advice\\|alias\\|generic\\|macro\\*?\\|method\\|"
                    "setf\\|subst\\*?\\|un\\*?\\|"
-                   "ine-\\(condition\\|derived-mode\\|function\\|"
+                   "ine-\\(condition\\|\\(?:derived\\|minor\\)-mode\\|"
                    "method-combination\\|setf-expander\\|skeleton\\|widget\\|"
-                   "\\(compiler\\|modify\\|symbol\\)-macro\\)\\)\\|"
+                   "function\\|\\(compiler\\|modify\\|symbol\\)-macro\\)\\)\\|"
                   ;; Variable declarations.
                   "\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|"
                   ;; Structure declarations.
@@ -3158,6 +3171,7 @@ See also `java-font-lock-extra-types'.")
 \f
 ;; Install ourselves:
 
+;; Useful for the popup-menu for mouse-3 on the modeline.
 (unless (assq 'font-lock-mode minor-mode-alist)
   (push '(font-lock-mode nil) minor-mode-alist))