diff options
| author | Stefan Monnier | 2013-01-12 20:23:48 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-01-12 20:23:48 -0500 |
| commit | e5b5a34dd1b9cd428e988d1bbc2af658c3e25daa (patch) | |
| tree | 3706c4fe486c3f2b2faad19510105d55a4d767a6 | |
| parent | 5ca9b80e95ef376d0247c813ae39eb2f476cf880 (diff) | |
| download | emacs-e5b5a34dd1b9cd428e988d1bbc2af658c3e25daa.tar.gz emacs-e5b5a34dd1b9cd428e988d1bbc2af658c3e25daa.zip | |
* lisp/jit-lock.el (jit-lock-debug-mode): New minor mode.
(jit-lock--debug-fontifying): New var.
(jit-lock--debug-fontify): New function.
* lisp/subr.el (condition-case-unless-debug): Don't prevent catching the
error, just let the debbugger run.
* lisp/emacs-lisp/timer.el (timer-event-handler): Don't prevent debugging
timer code and don't drop errors silently.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 4 | ||||
| -rw-r--r-- | lisp/jit-lock.el | 44 | ||||
| -rw-r--r-- | lisp/subr.el | 19 |
5 files changed, 67 insertions, 12 deletions
| @@ -66,6 +66,8 @@ bound to <f11> and M-<f10>, respectively. | |||
| 66 | 66 | ||
| 67 | * Changes in Specialized Modes and Packages in Emacs 24.4 | 67 | * Changes in Specialized Modes and Packages in Emacs 24.4 |
| 68 | 68 | ||
| 69 | ** jit-lock-debug-mode lets you use the debuggers on code run via jit-lock. | ||
| 70 | |||
| 69 | ** completing-read-multiple's separator can now be a regexp. | 71 | ** completing-read-multiple's separator can now be a regexp. |
| 70 | The default separator is changed to allow surrounding spaces around the comma. | 72 | The default separator is changed to allow surrounding spaces around the comma. |
| 71 | 73 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7723528c886..73e096adc5e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-01-13 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * jit-lock.el (jit-lock-debug-mode): New minor mode. | ||
| 4 | (jit-lock--debug-fontifying): New var. | ||
| 5 | (jit-lock--debug-fontify): New function. | ||
| 6 | * subr.el (condition-case-unless-debug): Don't prevent catching the | ||
| 7 | error, just let the debbugger run. | ||
| 8 | * emacs-lisp/timer.el (timer-event-handler): Don't prevent debugging | ||
| 9 | timer code and don't drop errors silently. | ||
| 10 | |||
| 1 | 2013-01-12 Michael Albinus <michael.albinus@gmx.de> | 11 | 2013-01-12 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 12 | ||
| 3 | * autorevert.el (auto-revert-notify-watch-descriptor): Give it | 13 | * autorevert.el (auto-revert-notify-watch-descriptor): Give it |
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 3eaacd24ec8..8b019d0a785 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -307,13 +307,13 @@ This function is called, by name, directly by the C code." | |||
| 307 | ;; Run handler. | 307 | ;; Run handler. |
| 308 | ;; We do this after rescheduling so that the handler function | 308 | ;; We do this after rescheduling so that the handler function |
| 309 | ;; can cancel its own timer successfully with cancel-timer. | 309 | ;; can cancel its own timer successfully with cancel-timer. |
| 310 | (condition-case nil | 310 | (condition-case-unless-debug err |
| 311 | ;; Timer functions should not change the current buffer. | 311 | ;; Timer functions should not change the current buffer. |
| 312 | ;; If they do, all kinds of nasty surprises can happen, | 312 | ;; If they do, all kinds of nasty surprises can happen, |
| 313 | ;; and it can be hellish to track down their source. | 313 | ;; and it can be hellish to track down their source. |
| 314 | (save-current-buffer | 314 | (save-current-buffer |
| 315 | (apply (timer--function timer) (timer--args timer))) | 315 | (apply (timer--function timer) (timer--args timer))) |
| 316 | (error nil)) | 316 | (error (message "Error in timer: %S" err))) |
| 317 | (if retrigger | 317 | (if retrigger |
| 318 | (setf (timer--triggered timer) nil))) | 318 | (setf (timer--triggered timer) nil))) |
| 319 | (error "Bogus timer event")))) | 319 | (error "Bogus timer event")))) |
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index 7be5df72c84..668f1ec963a 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el | |||
| @@ -257,6 +257,47 @@ the variable `jit-lock-stealth-nice'." | |||
| 257 | (remove-hook 'after-change-functions 'jit-lock-after-change t) | 257 | (remove-hook 'after-change-functions 'jit-lock-after-change t) |
| 258 | (remove-hook 'fontification-functions 'jit-lock-function)))) | 258 | (remove-hook 'fontification-functions 'jit-lock-function)))) |
| 259 | 259 | ||
| 260 | (define-minor-mode jit-lock-debug-mode | ||
| 261 | "Minor mode to help debug code run from jit-lock. | ||
| 262 | When this minor mode is enabled, jit-lock runs as little code as possible | ||
| 263 | during redisplay and moves the rest to a timer, where things | ||
| 264 | like `debug-on-error' and Edebug can be used." | ||
| 265 | :global t | ||
| 266 | (when jit-lock-defer-timer | ||
| 267 | (cancel-timer jit-lock-defer-timer) | ||
| 268 | (setq jit-lock-defer-timer nil)) | ||
| 269 | (when jit-lock-debug-mode | ||
| 270 | (setq jit-lock-defer-timer | ||
| 271 | (run-with-idle-timer 0 t #'jit-lock--debug-fontify)))) | ||
| 272 | |||
| 273 | (defvar jit-lock--debug-fontifying nil) | ||
| 274 | |||
| 275 | (defun jit-lock--debug-fontify () | ||
| 276 | "Fontify what was deferred for debugging." | ||
| 277 | (when (and (not jit-lock--debug-fontifying) | ||
| 278 | jit-lock-defer-buffers (not memory-full)) | ||
| 279 | (let ((jit-lock--debug-fontifying t) | ||
| 280 | (inhibit-debugger nil)) ;FIXME: Not sufficient! | ||
| 281 | ;; Mark the deferred regions back to `fontified = nil' | ||
| 282 | (dolist (buffer jit-lock-defer-buffers) | ||
| 283 | (when (buffer-live-p buffer) | ||
| 284 | (with-current-buffer buffer | ||
| 285 | ;; (message "Jit-Debug %s" (buffer-name)) | ||
| 286 | (with-buffer-prepared-for-jit-lock | ||
| 287 | (let ((pos (point-min))) | ||
| 288 | (while | ||
| 289 | (progn | ||
| 290 | (when (eq (get-text-property pos 'fontified) 'defer) | ||
| 291 | (let ((beg pos) | ||
| 292 | (end (setq pos (next-single-property-change | ||
| 293 | pos 'fontified | ||
| 294 | nil (point-max))))) | ||
| 295 | (put-text-property beg end 'fontified nil) | ||
| 296 | (jit-lock-fontify-now beg end))) | ||
| 297 | (setq pos (next-single-property-change | ||
| 298 | pos 'fontified))))))))) | ||
| 299 | (setq jit-lock-defer-buffers nil)))) | ||
| 300 | |||
| 260 | (defun jit-lock-register (fun &optional contextual) | 301 | (defun jit-lock-register (fun &optional contextual) |
| 261 | "Register FUN as a fontification function to be called in this buffer. | 302 | "Register FUN as a fontification function to be called in this buffer. |
| 262 | FUN will be called with two arguments START and END indicating the region | 303 | FUN will be called with two arguments START and END indicating the region |
| @@ -504,7 +545,8 @@ non-nil in a repeated invocation of this function." | |||
| 504 | pos (setq pos (next-single-property-change | 545 | pos (setq pos (next-single-property-change |
| 505 | pos 'fontified nil (point-max))) | 546 | pos 'fontified nil (point-max))) |
| 506 | 'fontified nil)) | 547 | 'fontified nil)) |
| 507 | (setq pos (next-single-property-change pos 'fontified))))))))) | 548 | (setq pos (next-single-property-change |
| 549 | pos 'fontified))))))))) | ||
| 508 | (setq jit-lock-defer-buffers nil) | 550 | (setq jit-lock-defer-buffers nil) |
| 509 | ;; Force fontification of the visible parts. | 551 | ;; Force fontification of the visible parts. |
| 510 | (let ((jit-lock-defer-timer nil)) | 552 | (let ((jit-lock-defer-timer nil)) |
diff --git a/lisp/subr.el b/lisp/subr.el index 11e882d9158..e1ab5298409 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3367,16 +3367,17 @@ If BODY finishes, `while-no-input' returns whatever value BODY produced." | |||
| 3367 | (progn ,@body))))))) | 3367 | (progn ,@body))))))) |
| 3368 | 3368 | ||
| 3369 | (defmacro condition-case-unless-debug (var bodyform &rest handlers) | 3369 | (defmacro condition-case-unless-debug (var bodyform &rest handlers) |
| 3370 | "Like `condition-case' except that it does not catch anything when debugging. | 3370 | "Like `condition-case' except that it does not prevent debugging. |
| 3371 | More specifically if `debug-on-error' is set, then it does not catch any signal." | 3371 | More specifically if `debug-on-error' is set then the debugger will be invoked |
| 3372 | even if this catches the signal." | ||
| 3372 | (declare (debug condition-case) (indent 2)) | 3373 | (declare (debug condition-case) (indent 2)) |
| 3373 | (let ((bodysym (make-symbol "body"))) | 3374 | `(condition-case ,var |
| 3374 | `(let ((,bodysym (lambda () ,bodyform))) | 3375 | ,bodyform |
| 3375 | (if debug-on-error | 3376 | ,@(mapcar (lambda (handler) |
| 3376 | (funcall ,bodysym) | 3377 | `((debug ,@(if (listp (car handler)) (car handler) |
| 3377 | (condition-case ,var | 3378 | (list (car handler)))) |
| 3378 | (funcall ,bodysym) | 3379 | ,@(cdr handler))) |
| 3379 | ,@handlers))))) | 3380 | handlers))) |
| 3380 | 3381 | ||
| 3381 | (define-obsolete-function-alias 'condition-case-no-debug | 3382 | (define-obsolete-function-alias 'condition-case-no-debug |
| 3382 | 'condition-case-unless-debug "24.1") | 3383 | 'condition-case-unless-debug "24.1") |