Commit 5a5987eb authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(jit-lock-mode): Force jit-refontify when turned on.

Use consistent make-local-variable style for font-lock-fontified.
(jit-lock-fontify-buffer):
Don't bother checking for font-lock-mode and jit-lock-mode.
parent c2acf685
...@@ -199,11 +199,14 @@ the variable `jit-lock-stealth-nice'." ...@@ -199,11 +199,14 @@ the variable `jit-lock-stealth-nice'."
;; Turn Just-in-time Lock mode on. ;; Turn Just-in-time Lock mode on.
(jit-lock-mode (jit-lock-mode
;; Mark the buffer for refontification
;; (in case spurious `fontified' text-props were left around).
(jit-lock-fontify-buffer)
;; Setting `font-lock-fontified' makes font-lock believe the ;; Setting `font-lock-fontified' makes font-lock believe the
;; buffer is already fontified, so that it won't highlight ;; buffer is already fontified, so that it won't highlight
;; the whole buffer or bail out on a large buffer. ;; the whole buffer or bail out on a large buffer.
(make-local-variable 'font-lock-fontified) (set (make-local-variable 'font-lock-fontified) t)
(setq font-lock-fontified t)
;; Setup JIT font-lock-fontify-buffer. ;; Setup JIT font-lock-fontify-buffer.
(unless jit-lock-saved-fontify-buffer-function (unless jit-lock-saved-fontify-buffer-function
...@@ -259,12 +262,10 @@ the variable `jit-lock-stealth-nice'." ...@@ -259,12 +262,10 @@ the variable `jit-lock-stealth-nice'."
;; things like CWarn mode which adds/removes a few keywords and ;; things like CWarn mode which adds/removes a few keywords and
;; does a refontify (which takes ages on large files). ;; does a refontify (which takes ages on large files).
(defun jit-lock-fontify-buffer () (defun jit-lock-fontify-buffer ()
(if (not (and font-lock-mode jit-lock-mode))
(funcall jit-lock-saved-fontify-buffer-function)
(with-buffer-prepared-for-font-lock (with-buffer-prepared-for-font-lock
(save-restriction (save-restriction
(widen) (widen)
(add-text-properties (point-min) (point-max) '(fontified nil)))))) (add-text-properties (point-min) (point-max) '(fontified nil)))))
;;; On demand fontification. ;;; On demand fontification.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment