aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2014-02-12 22:29:47 -0500
committerStefan Monnier2014-02-12 22:29:47 -0500
commiteb4c6947f5b0b7c8784059ee3a5a07904ad3b400 (patch)
treeba6815929d6289d972993165f0baa524f016366b
parent1a4c95f6640b266c792254480947894088cb37d3 (diff)
downloademacs-eb4c6947f5b0b7c8784059ee3a5a07904ad3b400.tar.gz
emacs-eb4c6947f5b0b7c8784059ee3a5a07904ad3b400.zip
* lisp/jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/jit-lock.el128
2 files changed, 71 insertions, 61 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a26bd91e5c5..19df506e3a1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12014-02-13 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
4
12014-02-13 Glenn Morris <rgm@gnu.org> 52014-02-13 Glenn Morris <rgm@gnu.org>
2 6
3 * finder.el (finder-known-keywords, finder-mode-map): Doc fixes. 7 * finder.el (finder-known-keywords, finder-mode-map): Doc fixes.
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index 34747568338..9f60ecb0126 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -191,67 +191,73 @@ If the system load rises above `jit-lock-stealth-load' percent, stealth
191fontification is suspended. Stealth fontification intensity is controlled via 191fontification is suspended. Stealth fontification intensity is controlled via
192the variable `jit-lock-stealth-nice'." 192the variable `jit-lock-stealth-nice'."
193 (setq jit-lock-mode arg) 193 (setq jit-lock-mode arg)
194 (cond (;; Turn Just-in-time Lock mode on. 194 (cond
195 jit-lock-mode 195 ((buffer-base-buffer)
196 196 ;; We're in an indirect buffer. This doesn't work because jit-lock relies
197 ;; Mark the buffer for refontification. 197 ;; on the `fontified' text-property which is shared with the base buffer.
198 (jit-lock-refontify) 198 (setq jit-lock-mode nil)
199 199 (message "Not enabling jit-lock: it does not work in indirect buffer"))
200 ;; Install an idle timer for stealth fontification. 200
201 (when (and jit-lock-stealth-time (null jit-lock-stealth-timer)) 201 (jit-lock-mode ;; Turn Just-in-time Lock mode on.
202 (setq jit-lock-stealth-timer 202
203 (run-with-idle-timer jit-lock-stealth-time t 203 ;; Mark the buffer for refontification.
204 'jit-lock-stealth-fontify))) 204 (jit-lock-refontify)
205 205
206 ;; Create, but do not activate, the idle timer for repeated 206 ;; Install an idle timer for stealth fontification.
207 ;; stealth fontification. 207 (when (and jit-lock-stealth-time (null jit-lock-stealth-timer))
208 (when (and jit-lock-stealth-time (null jit-lock-stealth-repeat-timer)) 208 (setq jit-lock-stealth-timer
209 (setq jit-lock-stealth-repeat-timer (timer-create)) 209 (run-with-idle-timer jit-lock-stealth-time t
210 (timer-set-function jit-lock-stealth-repeat-timer 210 'jit-lock-stealth-fontify)))
211 'jit-lock-stealth-fontify '(t))) 211
212 212 ;; Create, but do not activate, the idle timer for repeated
213 ;; Init deferred fontification timer. 213 ;; stealth fontification.
214 (when (and jit-lock-defer-time (null jit-lock-defer-timer)) 214 (when (and jit-lock-stealth-time (null jit-lock-stealth-repeat-timer))
215 (setq jit-lock-defer-timer 215 (setq jit-lock-stealth-repeat-timer (timer-create))
216 (run-with-idle-timer jit-lock-defer-time t 216 (timer-set-function jit-lock-stealth-repeat-timer
217 'jit-lock-deferred-fontify))) 217 'jit-lock-stealth-fontify '(t)))
218 218
219 ;; Initialize contextual fontification if requested. 219 ;; Init deferred fontification timer.
220 (when (eq jit-lock-contextually t) 220 (when (and jit-lock-defer-time (null jit-lock-defer-timer))
221 (unless jit-lock-context-timer 221 (setq jit-lock-defer-timer
222 (setq jit-lock-context-timer 222 (run-with-idle-timer jit-lock-defer-time t
223 (run-with-idle-timer jit-lock-context-time t 223 'jit-lock-deferred-fontify)))
224 'jit-lock-context-fontify))) 224
225 (setq jit-lock-context-unfontify-pos 225 ;; Initialize contextual fontification if requested.
226 (or jit-lock-context-unfontify-pos (point-max)))) 226 (when (eq jit-lock-contextually t)
227 227 (unless jit-lock-context-timer
228 ;; Setup our hooks. 228 (setq jit-lock-context-timer
229 (add-hook 'after-change-functions 'jit-lock-after-change nil t) 229 (run-with-idle-timer jit-lock-context-time t
230 (add-hook 'fontification-functions 'jit-lock-function)) 230 'jit-lock-context-fontify)))
231 231 (setq jit-lock-context-unfontify-pos
232 ;; Turn Just-in-time Lock mode off. 232 (or jit-lock-context-unfontify-pos (point-max))))
233 (t 233
234 ;; Cancel our idle timers. 234 ;; Setup our hooks.
235 (when (and (or jit-lock-stealth-timer jit-lock-defer-timer 235 (add-hook 'after-change-functions 'jit-lock-after-change nil t)
236 jit-lock-context-timer) 236 (add-hook 'fontification-functions 'jit-lock-function))
237 ;; Only if there's no other buffer using them. 237
238 (not (catch 'found 238 ;; Turn Just-in-time Lock mode off.
239 (dolist (buf (buffer-list)) 239 (t
240 (with-current-buffer buf 240 ;; Cancel our idle timers.
241 (when jit-lock-mode (throw 'found t))))))) 241 (when (and (or jit-lock-stealth-timer jit-lock-defer-timer
242 (when jit-lock-stealth-timer 242 jit-lock-context-timer)
243 (cancel-timer jit-lock-stealth-timer) 243 ;; Only if there's no other buffer using them.
244 (setq jit-lock-stealth-timer nil)) 244 (not (catch 'found
245 (when jit-lock-context-timer 245 (dolist (buf (buffer-list))
246 (cancel-timer jit-lock-context-timer) 246 (with-current-buffer buf
247 (setq jit-lock-context-timer nil)) 247 (when jit-lock-mode (throw 'found t)))))))
248 (when jit-lock-defer-timer 248 (when jit-lock-stealth-timer
249 (cancel-timer jit-lock-defer-timer) 249 (cancel-timer jit-lock-stealth-timer)
250 (setq jit-lock-defer-timer nil))) 250 (setq jit-lock-stealth-timer nil))
251 251 (when jit-lock-context-timer
252 ;; Remove hooks. 252 (cancel-timer jit-lock-context-timer)
253 (remove-hook 'after-change-functions 'jit-lock-after-change t) 253 (setq jit-lock-context-timer nil))
254 (remove-hook 'fontification-functions 'jit-lock-function)))) 254 (when jit-lock-defer-timer
255 (cancel-timer jit-lock-defer-timer)
256 (setq jit-lock-defer-timer nil)))
257
258 ;; Remove hooks.
259 (remove-hook 'after-change-functions 'jit-lock-after-change t)
260 (remove-hook 'fontification-functions 'jit-lock-function))))
255 261
256(define-minor-mode jit-lock-debug-mode 262(define-minor-mode jit-lock-debug-mode
257 "Minor mode to help debug code run from jit-lock. 263 "Minor mode to help debug code run from jit-lock.