(Command Loop Info, Adjusting Point): Remove @tindex.
[bpt/emacs.git] / lisp / font-lock.el
index be85783..207d3b8 100644 (file)
@@ -281,12 +281,6 @@ If a number, only buffers greater than this size have fontification messages."
                 (other :tag "always" t)
                 (integer :tag "size"))
   :group 'font-lock)
-
-(defcustom font-lock-lines-before 0
-  "*Number of lines before the changed text to include in refontification."
-  :type 'integer
-  :group 'font-lock
-  :version "22.1")
 \f
 
 ;; Originally these variable values were face names such as `bold' etc.
@@ -1039,7 +1033,7 @@ a very meaningful entity to highlight.")
          (when font-lock-syntax-table
            (set-syntax-table font-lock-syntax-table))
           (goto-char beg)
-          (setq beg (line-beginning-position (- 1 font-lock-lines-before)))
+         (setq beg (line-beginning-position))
          ;; check to see if we should expand the beg/end area for
          ;; proper multiline matches
          (when (and (> beg (point-min))
@@ -1090,13 +1084,17 @@ what properties to clear before refontifying a region.")
 ;; Called when any modification is made to buffer text.
 (defun font-lock-after-change-function (beg end old-len)
   (let ((inhibit-point-motion-hooks t)
-       (inhibit-quit t))
+       (inhibit-quit t)
+       (region (font-lock-extend-region beg end old-len)))
     (save-excursion
       (save-match-data
-       ;; Rescan between start of lines enclosing the region.
-       (font-lock-fontify-region
-        (progn (goto-char beg) (forward-line 0) (point))
-        (progn (goto-char end) (forward-line 1) (point)))))))
+       (if region
+           ;; Fontify the region the major mode has specified.
+           (setq beg (car region) end (cdr region))
+         ;; Fontify the whole lines which enclose the region.
+         (setq beg (progn (goto-char beg) (line-beginning-position))
+               end (progn (goto-char end) (line-beginning-position 2))))
+       (font-lock-fontify-region beg end)))))
 
 (defun font-lock-fontify-block (&optional arg)
   "Fontify some lines the way `font-lock-fontify-buffer' would.
@@ -1976,17 +1974,17 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
 ;;
 ;;         (regexp-opt
 ;;          '("define"  "elif" "else" "endif" "error" "file" "if" "ifdef"
-;;            "ifndef" "include" "line" "pragma" "undef"))
+;;            "ifndef" "import" "include" "line" "pragma" "undef" "warning"))
 ;;
 (defconst cpp-font-lock-keywords-source-directives
-  "define\\|e\\(?:l\\(?:if\\|se\\)\\|ndif\\|rror\\)\\|file\\|i\\(?:f\\(?:n?def\\)?\\|nclude\\)\\|line\\|pragma\\|undef"
+  "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'.")
 
 ;; `cpp-font-lock-keywords-source-depth' is calculated from:
 ;;
 ;;          (regexp-opt-depth (regexp-opt
 ;;                    '("define"  "elif" "else" "endif" "error" "file" "if" "ifdef"
-;;                      "ifndef" "include" "line" "pragma" "undef")))
+;;                      "ifndef" "import" "include" "line" "pragma" "undef" "warning")))
 ;;
 (defconst cpp-font-lock-keywords-source-depth 0
   "An integer representing regular expression depth of `cpp-font-lock-keywords-source-directives'.
@@ -1998,7 +1996,7 @@ Used in `cpp-font-lock-keywords'.")
     (list
      ;;
      ;; Fontify error directives.
-     '("^#[ \t]*error[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend)
+     '("^#[ \t]*\\(?:error\\|warning\\)[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend)
      ;;
      ;; Fontify filenames in #include <...> preprocessor directives as strings.
      '("^#[ \t]*\\(?:import\\|include\\)[ \t]*\\(<[^>\"\n]*>?\\)"
@@ -2120,13 +2118,13 @@ other modes in which C preprocessor directives are used. e.g. `asm-mode' and
        ;; Erroneous structures.
        ("(\\(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)
+       ("\\\\\\\\\\[\\(\\sw+\\)\\]" 1 font-lock-constant-face prepend)
        ;; Words inside `' tend to be symbol names.
        ("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend)
        ;; Constant values.
        ("\\<:\\sw+\\>" 0 font-lock-builtin-face)
        ;; ELisp and CLisp `&' keywords as types.
-       ("\\&\\sw+\\>" . font-lock-type-face)
+       ("\\<\\&\\sw+\\>" . font-lock-type-face)
        ;; ELisp regexp grouping constructs
        ((lambda (bound)
           (catch 'found