changeset 32483:09a7b2ac5750

(font-lock-syntactically-fontified): New var. (font-lock-fontify-syntactic-keywords-region): Use it. (font-lock-mode): Fix docstring. Don't need make-local-hook anymore.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 15 Oct 2000 04:51:57 +0000
parents 3e97369732ac
children bb1bfa010bf3
files lisp/font-lock.el
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/font-lock.el	Sun Oct 15 04:49:55 2000 +0000
+++ b/lisp/font-lock.el	Sun Oct 15 04:51:57 2000 +0000
@@ -511,6 +511,12 @@
   "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
 This is normally set via `font-lock-defaults'.")
 
+(defvar font-lock-syntactically-fontified 0
+  "Point up to which `font-lock-syntactic-keywords' has been applied.
+If nil, this is ignored, in which case the syntactic fontification may
+sometimes be slightly incorrect.")
+(make-variable-buffer-local 'font-lock-syntactically-fontified)
+
 (defvar font-lock-syntactic-keywords nil
   "A list of the syntactic keywords to highlight.
 Can be the list or the name of a function or variable whose value is the list.
@@ -638,7 +644,7 @@
 (defun font-lock-mode (&optional arg)
   "Toggle Font Lock mode.
 With arg, turn Font Lock mode on if and only if arg is positive.
-(Font Lock is also known as \"syntax highlighting\".)
+\(Font Lock is also known as \"syntax highlighting\".)
 
 When Font Lock mode is enabled, text is fontified as you type it:
 
@@ -699,7 +705,6 @@
     (set (make-local-variable 'font-lock-mode) on-p)
     ;; Turn on Font Lock mode.
     (when on-p
-      (make-local-hook 'after-change-functions)
       (add-hook 'after-change-functions 'font-lock-after-change-function nil t)
       (font-lock-set-defaults)
       (font-lock-turn-on-thing-lock)
@@ -1447,6 +1452,11 @@
 (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))
   ;; 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