aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1994-02-01 01:32:48 +0000
committerKarl Heuer1994-02-01 01:32:48 +0000
commit7daa8d6b1c2c0bf611ab977240e514661fbef214 (patch)
tree34c0b3139d2e1db420d37f2d9616216e0f3e0dfd
parent4fbf62eea8852339a86347cc94e1dc31d643a478 (diff)
downloademacs-7daa8d6b1c2c0bf611ab977240e514661fbef214.tar.gz
emacs-7daa8d6b1c2c0bf611ab977240e514661fbef214.zip
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
-rw-r--r--lisp/font-lock.el21
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index 9ce1ed1e8bc..d0c042d39d3 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -365,17 +365,32 @@ can use \\[font-lock-fontify-buffer]."
365 (set (make-local-variable 'font-lock-mode) on-p) 365 (set (make-local-variable 'font-lock-mode) on-p)
366 (cond (on-p 366 (cond (on-p
367 (font-lock-set-defaults) 367 (font-lock-set-defaults)
368 (make-local-variable 'before-revert-hook)
368 (make-local-variable 'after-revert-hook) 369 (make-local-variable 'after-revert-hook)
369 ;;if buffer is reverted, must repeat fontification. 370 ;; If buffer is reverted, must clean up the state.
370 (setq after-revert-hook 'font-lock-fontify-buffer) 371 (add-hook 'before-revert-hook 'font-lock-revert-setup)
372 (add-hook 'after-revert-hook 'font-lock-revert-cleanup)
371 (run-hooks 'font-lock-mode-hook) 373 (run-hooks 'font-lock-mode-hook)
372 (or font-lock-fontified (font-lock-fontify-buffer))) 374 (or font-lock-fontified (font-lock-fontify-buffer)))
373 (font-lock-fontified 375 (font-lock-fontified
374 (setq font-lock-fontified nil) 376 (setq font-lock-fontified nil)
375 (setq after-revert-hook nil) 377 (remove-hook 'before-revert-hook 'font-lock-revert-setup)
378 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
376 (font-lock-unfontify-region (point-min) (point-max)))) 379 (font-lock-unfontify-region (point-min) (point-max))))
377 (force-mode-line-update))) 380 (force-mode-line-update)))
378 381
382;; If the buffer is about to be reverted, it won't be fontified.
383(defun font-lock-revert-setup ()
384 (setq font-lock-fontified nil))
385
386;; If the buffer has just been reverted, we might not even be in font-lock
387;; mode anymore, and if we are, the buffer may or may not have already been
388;; refontified. Refontify here if it looks like we need to.
389(defun font-lock-revert-cleanup ()
390 (and font-lock-mode
391 (not font-lock-fontified)
392 (font-lock-mode 1)))
393
379(defun font-lock-fontify-buffer () 394(defun font-lock-fontify-buffer ()
380 "Fontify the current buffer the way `font-lock-mode' would: 395 "Fontify the current buffer the way `font-lock-mode' would:
381 396