emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r116426: * lisp/jit-lock.el (jit-lock-mode): Keep it


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r116426: * lisp/jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
Date: Thu, 13 Feb 2014 03:29:51 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116426
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2014-02-12 22:29:47 -0500
message:
  * lisp/jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/jit-lock.el               jitlock.el-20091113204419-o5vbwnq5f7feedwu-1321
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-02-13 02:31:48 +0000
+++ b/lisp/ChangeLog    2014-02-13 03:29:47 +0000
@@ -1,3 +1,7 @@
+2014-02-13  Stefan Monnier  <address@hidden>
+
+       * jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
+
 2014-02-13  Glenn Morris  <address@hidden>
 
        * finder.el (finder-known-keywords, finder-mode-map): Doc fixes.

=== modified file 'lisp/jit-lock.el'
--- a/lisp/jit-lock.el  2014-02-10 21:43:01 +0000
+++ b/lisp/jit-lock.el  2014-02-13 03:29:47 +0000
@@ -191,67 +191,73 @@
 fontification is suspended.  Stealth fontification intensity is controlled via
 the variable `jit-lock-stealth-nice'."
   (setq jit-lock-mode arg)
-  (cond (;; Turn Just-in-time Lock mode on.
-        jit-lock-mode
-
-        ;; Mark the buffer for refontification.
-        (jit-lock-refontify)
-
-        ;; Install an idle timer for stealth fontification.
-        (when (and jit-lock-stealth-time (null jit-lock-stealth-timer))
-          (setq jit-lock-stealth-timer
-                (run-with-idle-timer jit-lock-stealth-time t
-                                     'jit-lock-stealth-fontify)))
-
-        ;; Create, but do not activate, the idle timer for repeated
-        ;; stealth fontification.
-        (when (and jit-lock-stealth-time (null jit-lock-stealth-repeat-timer))
-          (setq jit-lock-stealth-repeat-timer (timer-create))
-          (timer-set-function jit-lock-stealth-repeat-timer
-                              'jit-lock-stealth-fontify '(t)))
-
-        ;; Init deferred fontification timer.
-        (when (and jit-lock-defer-time (null jit-lock-defer-timer))
-          (setq jit-lock-defer-timer
-                (run-with-idle-timer jit-lock-defer-time t
-                                     'jit-lock-deferred-fontify)))
-
-        ;; Initialize contextual fontification if requested.
-        (when (eq jit-lock-contextually t)
-          (unless jit-lock-context-timer
-            (setq jit-lock-context-timer
-                  (run-with-idle-timer jit-lock-context-time t
-                                       'jit-lock-context-fontify)))
-          (setq jit-lock-context-unfontify-pos
-                (or jit-lock-context-unfontify-pos (point-max))))
-
-        ;; Setup our hooks.
-        (add-hook 'after-change-functions 'jit-lock-after-change nil t)
-        (add-hook 'fontification-functions 'jit-lock-function))
-
-       ;; Turn Just-in-time Lock mode off.
-       (t
-        ;; Cancel our idle timers.
-        (when (and (or jit-lock-stealth-timer jit-lock-defer-timer
-                       jit-lock-context-timer)
-                   ;; Only if there's no other buffer using them.
-                   (not (catch 'found
-                          (dolist (buf (buffer-list))
-                            (with-current-buffer buf
-                              (when jit-lock-mode (throw 'found t)))))))
-          (when jit-lock-stealth-timer
-            (cancel-timer jit-lock-stealth-timer)
-            (setq jit-lock-stealth-timer nil))
-          (when jit-lock-context-timer
-            (cancel-timer jit-lock-context-timer)
-            (setq jit-lock-context-timer nil))
-          (when jit-lock-defer-timer
-            (cancel-timer jit-lock-defer-timer)
-            (setq jit-lock-defer-timer nil)))
-
-        ;; Remove hooks.
-        (remove-hook 'after-change-functions 'jit-lock-after-change t)
-        (remove-hook 'fontification-functions 'jit-lock-function))))
+  (cond
+   ((buffer-base-buffer)
+    ;; We're in an indirect buffer.  This doesn't work because jit-lock relies
+    ;; on the `fontified' text-property which is shared with the base buffer.
+    (setq jit-lock-mode nil)
+    (message "Not enabling jit-lock: it does not work in indirect buffer"))
+
+   (jit-lock-mode ;; Turn Just-in-time Lock mode on.
+
+    ;; Mark the buffer for refontification.
+    (jit-lock-refontify)
+
+    ;; Install an idle timer for stealth fontification.
+    (when (and jit-lock-stealth-time (null jit-lock-stealth-timer))
+      (setq jit-lock-stealth-timer
+            (run-with-idle-timer jit-lock-stealth-time t
+                                 'jit-lock-stealth-fontify)))
+
+    ;; Create, but do not activate, the idle timer for repeated
+    ;; stealth fontification.
+    (when (and jit-lock-stealth-time (null jit-lock-stealth-repeat-timer))
+      (setq jit-lock-stealth-repeat-timer (timer-create))
+      (timer-set-function jit-lock-stealth-repeat-timer
+                          'jit-lock-stealth-fontify '(t)))
+
+    ;; Init deferred fontification timer.
+    (when (and jit-lock-defer-time (null jit-lock-defer-timer))
+      (setq jit-lock-defer-timer
+            (run-with-idle-timer jit-lock-defer-time t
+                                 'jit-lock-deferred-fontify)))
+
+    ;; Initialize contextual fontification if requested.
+    (when (eq jit-lock-contextually t)
+      (unless jit-lock-context-timer
+        (setq jit-lock-context-timer
+              (run-with-idle-timer jit-lock-context-time t
+                                   'jit-lock-context-fontify)))
+      (setq jit-lock-context-unfontify-pos
+            (or jit-lock-context-unfontify-pos (point-max))))
+
+    ;; Setup our hooks.
+    (add-hook 'after-change-functions 'jit-lock-after-change nil t)
+    (add-hook 'fontification-functions 'jit-lock-function))
+
+   ;; Turn Just-in-time Lock mode off.
+   (t
+    ;; Cancel our idle timers.
+    (when (and (or jit-lock-stealth-timer jit-lock-defer-timer
+                   jit-lock-context-timer)
+               ;; Only if there's no other buffer using them.
+               (not (catch 'found
+                      (dolist (buf (buffer-list))
+                        (with-current-buffer buf
+                          (when jit-lock-mode (throw 'found t)))))))
+      (when jit-lock-stealth-timer
+        (cancel-timer jit-lock-stealth-timer)
+        (setq jit-lock-stealth-timer nil))
+      (when jit-lock-context-timer
+        (cancel-timer jit-lock-context-timer)
+        (setq jit-lock-context-timer nil))
+      (when jit-lock-defer-timer
+        (cancel-timer jit-lock-defer-timer)
+        (setq jit-lock-defer-timer nil)))
+
+    ;; Remove hooks.
+    (remove-hook 'after-change-functions 'jit-lock-after-change t)
+    (remove-hook 'fontification-functions 'jit-lock-function))))
 
 (define-minor-mode jit-lock-debug-mode
   "Minor mode to help debug code run from jit-lock.


reply via email to

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