summaryrefslogtreecommitdiff
path: root/lisp/font-lock.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2012-02-26 13:02:52 +0000
committerAlan Mackenzie <acm@muc.de>2012-02-26 13:02:52 +0000
commit487915d7385aeef679d9a6f077f319540835da4c (patch)
treee0b0d93fcf491e6e9e506a54aaeba7a4b5f22a81 /lisp/font-lock.el
parentc2c792605f7ea40e5e9a02c1ee701bcc33db8bdf (diff)
downloademacs-487915d7385aeef679d9a6f077f319540835da4c.tar.gz
Check there is a font-lock specification before initial fontification.
Diffstat (limited to 'lisp/font-lock.el')
-rw-r--r--lisp/font-lock.el28
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index a65a2c94c7d..7750b30f096 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -629,17 +629,29 @@ Major/minor modes can set this variable if they know which option applies.")
;; Shut up the byte compiler.
(defvar font-lock-face-attributes)) ; Obsolete but respected if set.
+(defun font-lock-spec-present (mode)
+ ;; Is there enough specification to do fontification at all?
+ (or font-lock-defaults
+ (if (boundp 'font-lock-keywords) font-lock-keywords)
+ (and mode
+ (boundp 'font-lock-set-defaults)
+ font-lock-set-defaults
+ font-lock-major-mode
+ (not (eq font-lock-major-mode major-mode)))))
+
(defun font-lock-initial-fontify ()
;; The first fontification after turning the mode on. This must
;; only be called after the mode hooks have been run.
- (let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size)))
- (cond (font-lock-fontified
- nil)
- ((or (null max-size) (> max-size (buffer-size)))
- (font-lock-fontify-buffer))
- (font-lock-verbose
- (message "Fontifying %s...buffer size greater than font-lock-maximum-size"
- (buffer-name))))))
+ (when (and font-lock-mode
+ (font-lock-spec-present t))
+ (let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size)))
+ (cond (font-lock-fontified
+ nil)
+ ((or (null max-size) (> max-size (buffer-size)))
+ (font-lock-fontify-buffer))
+ (font-lock-verbose
+ (message "Fontifying %s...buffer size greater than font-lock-maximum-size"
+ (buffer-name)))))))
(defun font-lock-mode-internal (arg)
;; Turn on Font Lock mode.