comparison lisp/jit-lock.el @ 29708:f37b857741b1

(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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 17 Jun 2000 17:17:35 +0000
parents ce16b083b459
children baa52c9029f6
comparison
equal deleted inserted replaced
29707:a70985b2a88f 29708:f37b857741b1
197 (let ((font-lock-support-mode 'jit-lock-mode)) 197 (let ((font-lock-support-mode 'jit-lock-mode))
198 (font-lock-mode t))) 198 (font-lock-mode t)))
199 199
200 ;; Turn Just-in-time Lock mode on. 200 ;; Turn Just-in-time Lock mode on.
201 (jit-lock-mode 201 (jit-lock-mode
202 ;; Mark the buffer for refontification
203 ;; (in case spurious `fontified' text-props were left around).
204 (jit-lock-fontify-buffer)
205
202 ;; Setting `font-lock-fontified' makes font-lock believe the 206 ;; Setting `font-lock-fontified' makes font-lock believe the
203 ;; buffer is already fontified, so that it won't highlight 207 ;; buffer is already fontified, so that it won't highlight
204 ;; the whole buffer or bail out on a large buffer. 208 ;; the whole buffer or bail out on a large buffer.
205 (make-local-variable 'font-lock-fontified) 209 (set (make-local-variable 'font-lock-fontified) t)
206 (setq font-lock-fontified t)
207 210
208 ;; Setup JIT font-lock-fontify-buffer. 211 ;; Setup JIT font-lock-fontify-buffer.
209 (unless jit-lock-saved-fontify-buffer-function 212 (unless jit-lock-saved-fontify-buffer-function
210 (set (make-local-variable 'jit-lock-saved-fontify-buffer-function) 213 (set (make-local-variable 'jit-lock-saved-fontify-buffer-function)
211 font-lock-fontify-buffer-function) 214 font-lock-fontify-buffer-function)
257 ;; This function is used to prevent font-lock-fontify-buffer from 260 ;; This function is used to prevent font-lock-fontify-buffer from
258 ;; fontifying eagerly the whole buffer. This is important for 261 ;; fontifying eagerly the whole buffer. This is important for
259 ;; things like CWarn mode which adds/removes a few keywords and 262 ;; things like CWarn mode which adds/removes a few keywords and
260 ;; does a refontify (which takes ages on large files). 263 ;; does a refontify (which takes ages on large files).
261 (defun jit-lock-fontify-buffer () 264 (defun jit-lock-fontify-buffer ()
262 (if (not (and font-lock-mode jit-lock-mode)) 265 (with-buffer-prepared-for-font-lock
263 (funcall jit-lock-saved-fontify-buffer-function) 266 (save-restriction
264 (with-buffer-prepared-for-font-lock 267 (widen)
265 (save-restriction 268 (add-text-properties (point-min) (point-max) '(fontified nil)))))
266 (widen)
267 (add-text-properties (point-min) (point-max) '(fontified nil))))))
268 269
269 270
270 ;;; On demand fontification. 271 ;;; On demand fontification.
271 272
272 (defun jit-lock-function (start) 273 (defun jit-lock-function (start)