aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2004-01-30 00:08:38 +0000
committerStefan Monnier2004-01-30 00:08:38 +0000
commitf415f2d726bbaf8f3b5ac9d87a00ad61ec39cd79 (patch)
tree0ccc9c9e67f2613e5d4eadc2d52096f379b8d85b
parentab43c85050514d20dff26eeec448a8970d3a0f53 (diff)
downloademacs-f415f2d726bbaf8f3b5ac9d87a00ad61ec39cd79.tar.gz
emacs-f415f2d726bbaf8f3b5ac9d87a00ad61ec39cd79.zip
(jit-lock-stealth-fontify): Allow quit.
(jit-lock-fontify-now): Handle the `quit' case. (jit-lock-contextually): Rename from jit-lock-defer-contextually.
-rw-r--r--lisp/jit-lock.el35
1 files changed, 20 insertions, 15 deletions
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index 93cbe4fe72e..3a0e3911fa8 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -115,15 +115,16 @@ See also `jit-lock-stealth-nice'."
115 :group 'jit-lock) 115 :group 'jit-lock)
116 116
117 117
118(defcustom jit-lock-defer-contextually 'syntax-driven 118(defvaralias 'jit-lock-defer-contextually 'jit-lock-contextually)
119 "*If non-nil, means deferred fontification should be syntactically true. 119(defcustom jit-lock-contextually 'syntax-driven
120If nil, means deferred fontification occurs only on those lines modified. This 120 "*If non-nil, means fontification should be syntactically true.
121If nil, means fontification occurs only on those lines modified. This
121means where modification on a line causes syntactic change on subsequent lines, 122means where modification on a line causes syntactic change on subsequent lines,
122those subsequent lines are not refontified to reflect their new context. 123those subsequent lines are not refontified to reflect their new context.
123If t, means deferred fontification occurs on those lines modified and all 124If t, means fontification occurs on those lines modified and all
124subsequent lines. This means those subsequent lines are refontified to reflect 125subsequent lines. This means those subsequent lines are refontified to reflect
125their new syntactic context, either immediately or when scrolling into them. 126their new syntactic context, either immediately or when scrolling into them.
126If any other value, e.g., `syntax-driven', means deferred syntactically true 127If any other value, e.g., `syntax-driven', means syntactically true
127fontification occurs only if syntactic fontification is performed using the 128fontification occurs only if syntactic fontification is performed using the
128buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil. 129buffer mode's syntax table, i.e., only if `font-lock-keywords-only' is nil.
129 130
@@ -187,7 +188,7 @@ following ways:
187 been idle for `jit-lock-stealth-time' seconds, while Emacs remains idle. 188 been idle for `jit-lock-stealth-time' seconds, while Emacs remains idle.
188 This is useful if any buffer has any deferred fontification. 189 This is useful if any buffer has any deferred fontification.
189 190
190- Deferred context fontification if `jit-lock-defer-contextually' is 191- Deferred context fontification if `jit-lock-contextually' is
191 non-nil. This means fontification updates the buffer corresponding to 192 non-nil. This means fontification updates the buffer corresponding to
192 true syntactic context, after `jit-lock-stealth-time' seconds of Emacs 193 true syntactic context, after `jit-lock-stealth-time' seconds of Emacs
193 idle time, while Emacs remains idle. Otherwise, fontification occurs 194 idle time, while Emacs remains idle. Otherwise, fontification occurs
@@ -219,7 +220,7 @@ the variable `jit-lock-stealth-nice'."
219 'jit-lock-deferred-fontify))) 220 'jit-lock-deferred-fontify)))
220 221
221 ;; Initialize contextual fontification if requested. 222 ;; Initialize contextual fontification if requested.
222 (when (eq jit-lock-defer-contextually t) 223 (when (eq jit-lock-contextually t)
223 (setq jit-lock-context-unfontify-pos 224 (setq jit-lock-context-unfontify-pos
224 (or jit-lock-context-unfontify-pos (point-max)))) 225 (or jit-lock-context-unfontify-pos (point-max))))
225 226
@@ -254,8 +255,8 @@ FUN will be called with two arguments START and END indicating the region
254that needs to be (re)fontified. 255that needs to be (re)fontified.
255If non-nil, CONTEXTUAL means that a contextual fontification would be useful." 256If non-nil, CONTEXTUAL means that a contextual fontification would be useful."
256 (add-hook 'jit-lock-functions fun nil t) 257 (add-hook 'jit-lock-functions fun nil t)
257 (when (and contextual jit-lock-defer-contextually) 258 (when (and contextual jit-lock-contextually)
258 (set (make-local-variable 'jit-lock-defer-contextually) t)) 259 (set (make-local-variable 'jit-lock-contextually) t))
259 (jit-lock-mode t)) 260 (jit-lock-mode t))
260 261
261(defun jit-lock-unregister (fun) 262(defun jit-lock-unregister (fun)
@@ -336,7 +337,13 @@ Defaults to the whole buffer. END can be out of bounds."
336 ;; We mark it first, to make sure that we don't indefinitely 337 ;; We mark it first, to make sure that we don't indefinitely
337 ;; re-execute this fontification if an error occurs. 338 ;; re-execute this fontification if an error occurs.
338 (put-text-property start next 'fontified t) 339 (put-text-property start next 'fontified t)
339 (run-hook-with-args 'jit-lock-functions start next) 340 (condition-case err
341 (run-hook-with-args 'jit-lock-functions start next)
342 ;; If the user quits (which shouldn't happen in normal on-the-fly
343 ;; jit-locking), make sure the fontification will be performed
344 ;; before displaying the block again.
345 (quit (put-text-property start next 'fontified nil)
346 (funcall 'signal (car err) (cdr err))))
340 347
341 ;; Find the start of the next chunk, if any. 348 ;; Find the start of the next chunk, if any.
342 (setq start (text-property-any next end 'fontified nil)))))))) 349 (setq start (text-property-any next end 'fontified nil))))))))
@@ -396,11 +403,9 @@ This functions is called after Emacs has been idle for
396 (let ((buffers (buffer-list)) 403 (let ((buffers (buffer-list))
397 minibuffer-auto-raise 404 minibuffer-auto-raise
398 message-log-max) 405 message-log-max)
399 (while (and buffers (not (input-pending-p))) 406 (with-local-quit
400 (let ((buffer (car buffers))) 407 (while (and buffers (not (input-pending-p)))
401 (setq buffers (cdr buffers)) 408 (with-current-buffer (pop buffers)
402
403 (with-current-buffer buffer
404 (when jit-lock-mode 409 (when jit-lock-mode
405 ;; This is funny. Calling sit-for with 3rd arg non-nil 410 ;; This is funny. Calling sit-for with 3rd arg non-nil
406 ;; so that it doesn't redisplay, internally calls 411 ;; so that it doesn't redisplay, internally calls