Re: Simple trick to block Terminal popup
Hi, this minimal debugger works neatly. Thanks!
(defun my-error-handler (&rest l)
(let ((backtrace (with-output-to-string (stream)
(dbg:output-backtrace t stream))))
(princ (car l))
(terpri)
(princ backtrace)
(abort)))
(setq *debugger-hook* 'my-error-handler)
CL-USER 15 > a
The variable A is unbound.
Interpreted call to MY-ERROR-HANDLER
Call to INVOKE-DEBUGGER
Call to EVAL
Call to CAPI::CAPI-TOP-LEVEL-FUNCTION
Call to CAPI::INTERACTIVE-PANE-TOP-LOOP
Call to (SUBFUNCTION MP::PROCESS-SG-FUNCTION MP::INITIALIZE-PROCESS-STACK)
Pekka
> >>>>> On Fri, 26 Jun 2009 16:03:35 +0300, Pekka Tolonen said:
>>
>> Hi, this works:
>>
> > (defun my-error-handler (&rest l)
>> (princ (car l))
>> (abort))
>>
>> (setq *debugger-hook* 'my-error-handler)
> >
>> Questions
>>
>> 1. Only glitch is that when dot or comma is entered on Listener
>> then the error is printed before prompt, but not after like
>> when entering unbound variable, or (/ 1 0), for example.
>> Why it is printed before prompt, and how to make it print after?
>
>Sorry, there is no API to change that. The error occurs while the Listener is
>reading, which makes it print random messages before the prompt so they do not
>get mixed up with the input you have typed.
>
>
>> 2. Does (abort) return to the top level as :top in Terminal would do,
>> cleaning up it all properly?
>
>It actually behaves like :a rather than :top, but it does clean up properly.
>Of course, if you never get into the debugger, then :top and :a are probably
>the same thing.
>
>
>> 3. How to make my-error-handler list backtrace?
>
>Call (dbg:output-backtrace t).
>
>
>> I noticed that
>>
>> (defun my-error-handler (&rest l)
>> (princ (car l))
>> (dbg::abort-to-top-level))
>>
>> lists EVERY SECOND TIME error by case CL-USER 7, then case CL-USER 8,
>> etc..
>
>You can't expect to get sensible results by calling the internal function
>dbg::abort-to-top-level.
>
>--
>Martin Simmons
>LispWorks Ltd
>http://www.lispworks.com/