emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107441: Check there is a font-lock s


From: Alan Mackenzie
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107441: Check there is a font-lock specification before initial fontification.
Date: Sun, 26 Feb 2012 13:02:52 +0000
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107441
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sun 2012-02-26 13:02:52 +0000
message:
  Check there is a font-lock specification before initial fontification.
modified:
  lisp/ChangeLog
  lisp/font-core.el
  lisp/font-lock.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-02-26 09:38:45 +0000
+++ b/lisp/ChangeLog    2012-02-26 13:02:52 +0000
@@ -1,3 +1,16 @@
+2012-02-26  Alan Mackenzie  <address@hidden>
+
+       Check there is a font-lock specification before doing initial
+       fontification.
+
+       * font-core.el (font-lock-mode): Move the conditional from
+       :after-hook to font-lock-initial-fontify.
+       (font-lock-default-function): Move the check for a specification
+       to font-lock-spec-present.
+
+       * font-lock.el (font-lock-initial-fontify): call ...
+       (font-lock-spec-present): New function.
+
 2012-02-26  Jim Blandy  <address@hidden>
 
        * progmodes/gdb-mi.el (gdb-mi-quote): New function.

=== modified file 'lisp/font-core.el'
--- a/lisp/font-core.el 2012-02-23 18:51:22 +0000
+++ b/lisp/font-core.el 2012-02-26 13:02:52 +0000
@@ -138,7 +138,7 @@
 your own function which is called when `font-lock-mode' is toggled via
 `font-lock-function'. "
   nil nil nil
-  :after-hook (if font-lock-mode (font-lock-initial-fontify))
+  :after-hook (font-lock-initial-fontify)
   ;; Don't turn on Font Lock mode if we don't have a display (we're running a
   ;; batch job) or if the buffer is invisible (the name starts with a space).
   (when (or noninteractive (eq (aref (buffer-name) 0) ?\s))
@@ -192,13 +192,7 @@
 
   ;; Only do hard work if the mode has specified stuff in
   ;; `font-lock-defaults'.
-  (when (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))))
+  (when (font-lock-spec-present mode)
     (font-lock-mode-internal mode)))
 
 (defun turn-on-font-lock ()

=== modified file 'lisp/font-lock.el'
--- a/lisp/font-lock.el 2012-02-23 18:51:22 +0000
+++ b/lisp/font-lock.el 2012-02-26 13:02:52 +0000
@@ -629,17 +629,29 @@
   ;; 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]