summaryrefslogtreecommitdiff
path: root/lisp/font-lock.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2000-10-15 04:51:57 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2000-10-15 04:51:57 +0000
commitc0a6a9fe280b6cc1efb87d982f4ec073627d3816 (patch)
tree88c4e31cef0032256bd910ccd082086e7aaf27f6 /lisp/font-lock.el
parent30cdf899d795651977cd4b4b761671024f06f747 (diff)
downloademacs-c0a6a9fe280b6cc1efb87d982f4ec073627d3816.tar.gz
(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.
Diffstat (limited to 'lisp/font-lock.el')
-rw-r--r--lisp/font-lock.el14
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 54dfe17de5a..a6b05e5f870 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -511,6 +511,12 @@ This is normally set via `font-lock-defaults'.")
"*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 @@ Major/minor modes can set this variable if they know which option applies.")
(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 @@ buffer local value for `font-lock-defaults', via its mode hook."
(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 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM."
(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