]> code.delx.au - gnu-emacs/blobdiff - lisp/font-lock.el
Much whitespace and capitalization change.
[gnu-emacs] / lisp / font-lock.el
index 0abe5f3806e9400f9ac738fccea0c30bf1b2982a..bdf31881cc47d392d9d1ff52795bd4713f992bbd 100644 (file)
@@ -1,7 +1,7 @@
 ;;; font-lock.el --- Electric font lock mode
 
-;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003, 2004
-;;  Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+;;   2000, 2001, 2002, 2003, 2004  Free Software Foundation, Inc.
 
 ;; Author: jwz, then rms, then sm
 ;; Maintainer: FSF
@@ -358,8 +358,9 @@ Each element in a user-level keywords list should have one of these forms:
  (eval . 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).
+call to make the search (called with one argument, the limit of the search;
+it should return non-nil, move point, and set `match-data' appropriately iff
+it succeeds; like `re-search-forward' would).
 MATCHER regexps can be generated via the function `regexp-opt'.
 
 FORM is an expression, whose value should be a keyword element, evaluated when
@@ -693,7 +694,7 @@ see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types',
           ;; If the keywords were compiled before, compile them again.
           (if was-compiled
               (set (make-local-variable 'font-lock-keywords)
-                   (font-lock-compile-keywords keywords t)))))))
+                   (font-lock-compile-keywords font-lock-keywords t)))))))
 
 (defun font-lock-update-removed-keyword-alist (mode keywords append)
   ;; Update `font-lock-removed-keywords-alist' when adding new
@@ -801,7 +802,7 @@ subtle problems due to details of the implementation."
           ;; If the keywords were compiled before, compile them again.
           (if was-compiled
               (set (make-local-variable 'font-lock-keywords)
-                   (font-lock-compile-keywords keywords t)))))))
+                   (font-lock-compile-keywords font-lock-keywords t)))))))
 \f
 ;;; Font Lock Support mode.
 
@@ -1257,7 +1258,7 @@ START should be at the beginning of a line."
                                        font-lock-syntactic-keywords)))
   ;; Get down to business.
   (let ((case-fold-search font-lock-keywords-case-fold-search)
-       (keywords (cdr font-lock-syntactic-keywords))
+       (keywords (cddr font-lock-syntactic-keywords))
        keyword matcher highlights)
     (while keywords
       ;; Find an occurrence of `matcher' from `start' to `end'.
@@ -1288,7 +1289,7 @@ START should be at the beginning of a line."
     (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
     (goto-char start)
     ;;
-    ;; Find the state at the `beginning-of-line' before `start'.
+    ;; Find the `start' state.
     (setq state (or ppss (syntax-ppss start)))
     ;;
     ;; Find each interesting place between here and `end'.
@@ -1300,9 +1301,9 @@ START should be at the beginning of a line."
            (setq state (parse-partial-sexp (point) end nil nil state
                                            'syntax-table))
            (when face (put-text-property beg (point) 'face face)))
-         (setq state (parse-partial-sexp (point) end nil nil state
-                                         'syntax-table))
-         (< (point) end)))))
+         (< (point) end))
+      (setq state (parse-partial-sexp (point) end nil nil state
+                                     'syntax-table)))))
 
 ;;; End of Syntactic fontification functions.
 \f
@@ -1323,6 +1324,12 @@ HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'."
          (add-text-properties start end (cddr val))
          (setq val (cadr val)))
        (cond
+        ((not (or val (eq override t)))
+         ;; If `val' is nil, don't do anything.  It is important to do it
+         ;; explicitly, because when adding nil via things like
+         ;; font-lock-append-text-property, the property is actually
+         ;; changed from <face> to (<face>) which is undesirable.  --Stef
+         nil)
         ((not override)
          ;; Cannot override existing fontification.
          (or (text-property-not-all start end 'face nil)
@@ -1515,7 +1522,9 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
     (make-local-variable 'font-lock-fontified)
     (make-local-variable 'font-lock-multiline)
     (let* ((defaults (or font-lock-defaults
-                        (cdr (assq major-mode font-lock-defaults-alist))))
+                        (cdr (assq major-mode
+                                   (with-no-warnings
+                                    font-lock-defaults-alist)))))
           (keywords
            (font-lock-choose-keywords (nth 0 defaults)
                                       (font-lock-value-in-major-mode font-lock-maximum-decoration)))
@@ -1561,7 +1570,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
       ;; Now compile the keywords.
       (unless (eq (car font-lock-keywords) t)
        (set (make-local-variable 'font-lock-keywords)
-            (font-lock-compile-keywords keywords t))))))
+            (font-lock-compile-keywords font-lock-keywords t))))))
 \f
 ;;; Colour etc. support.
 
@@ -1944,12 +1953,12 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
                  '("when" "unless" "case" "ecase" "typecase" "etypecase"
                    "ccase" "ctypecase" "handler-case" "handler-bind"
                    "restart-bind" "restart-case" "in-package"
-                   "cerror" "break" "ignore-errors"
+                   "break" "ignore-errors"
                    "loop" "do" "do*" "dotimes" "dolist" "the" "locally"
                    "proclaim" "declaim" "declare" "symbol-macrolet"
                    "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
-                   "destructuring-bind" "macrolet" "tagbody" "block"
-                   "multiple-value-bind"
+                   "destructuring-bind" "macrolet" "tagbody" "block" "go"
+                   "multiple-value-bind" "multiple-value-prog1"
                    "return" "return-from"
                    "with-accessors" "with-compilation-unit"
                    "with-condition-restarts" "with-hash-table-iterator"
@@ -1967,7 +1976,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
            '(2 font-lock-constant-face nil t))
       ;;
       ;; Erroneous structures.
-      '("(\\(abort\\|assert\\|error\\|signal\\)\\>" 1 font-lock-warning-face)
+      '("(\\(abort\\|assert\\|warn\\|check-type\\|cerror\\|error\\|signal\\)\\>" 1 font-lock-warning-face)
       ;;
       ;; Words inside \\[] tend to be for `substitute-command-keys'.
       '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-constant-face prepend)
@@ -1994,5 +2003,5 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
 \f
 (provide 'font-lock)
 
-;;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
+;; arch-tag: 682327e4-64d8-4057-b20b-1fbb9f1fc54c
 ;;; font-lock.el ends here