[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: blink-cursor-end sometimes fails and disrupts pre-command-hook
From: |
Ken Manheimer |
Subject: |
Re: blink-cursor-end sometimes fails and disrupts pre-command-hook |
Date: |
Tue, 22 Aug 2006 17:12:35 -0400 |
On 8/21/06, Stuart D. Herring <address@hidden> wrote:
> that said, i had failed to find/realize that debug-on-signal would
> cause a debug session at the point of error within the condition case.
> while not quite what i'm seeking, that will be helpful. is there a
> reasonable way to substitute a function for the debug session, so it
> could stash a backtrace and proceed on, rather than invoking user
> intervention?
C-h v debugger
Does that help?
that was the final piece i needed.
i've just barely started using it, but my post-command-hook has this fragment:
(condition-case failure
[...]
(when allout-widgets-changes-record
(let* ((debug-on-signal t)
(debug-on-error t)
(debugger 'allout-widgets-postcommand-hook-error-handler)
[process the pending changes]
[...]
))
(error (setq allout-widgets-changes-record nil))
and the handler looks like this:
(defun allout-widgets-postcommand-hook-error-handler (mode args)
"Process errors which occurred within the extent of a command hook.
We store a backtrace of the error information in the variable,
`allout-widgets-last-hook-error', unset the error handlers, and
reraise the error, so that processing continues to the
encompassing condition-case."
;; first deconstruct special error environment so errors here propagate
;; to encompassing condition-case:
(setq debugger 'debug
debug-on-error nil
debug-on-signal nil)
(let* ((bt (with-output-to-string (backtrace)))
(this "allout-widgets-postcommand-hook-error-handler")
(header
(format "allout-widgets-last-hook-error stored and posted, %s/%s %s"
this mode args
(format-time-string "%e-%b-%Y %r" (current-time)))))
;; post to *Messages* then immediately replace with more compact notice:
(message (setq allout-widgets-last-hook-error
(format "%s:\n%s" header bt)))
(message header) (sit-for allout-widgets-hook-error-post-time)
;; reraise the error, or one concerning this function if unexpected:
(if (equal mode 'error)
(apply 'signal args)
(error "%s: unexpected mode, %s %s" this mode args))))
i expect this to be very helpful tracking down errors while making my
post-command-hook a "good citizen", unlikely to disrupt the hook due
to uncaught errors.
thanks all for pointing out what i needed to do to record backtraces
at the point of failure.
--
ken
address@hidden
http://myriadicity.net
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, (continued)
Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Richard Stallman, 2006/08/20
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Ken Manheimer, 2006/08/20
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, David Kastrup, 2006/08/21
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Richard Stallman, 2006/08/21
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Ken Manheimer, 2006/08/21
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Stuart D. Herring, 2006/08/21
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook,
Ken Manheimer <=
- Re: blink-cursor-end sometimes fails and disrupts pre-command-hook, Richard Stallman, 2006/08/23