[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Random idea: Debugging `quit'
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: Random idea: Debugging `quit' |
Date: |
Sun, 11 Sep 2011 23:01:12 +0200 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) |
Helmut Eller <address@hidden> writes:
> Not so nice, but kill -SIGUSR2 <emacs-pid> in shell tells Emacs to
> enter the debugger.
I didn't know that. That sounds useful.
> Another possibility would be to set debug-on-quit permanently to t
> and at the same time set the variable debugger to some function
> that is smart enough to look at the queued events:
>
> (require 'cl)
> (require 'debug) ; load it now to avoid resetting debugger
> (setq debug-on-quit t)
> (setq debugger 'my-debug)
> (defun my-debug (&rest args)
> (cond ((equal args '(error (quit)))
> (let ((unread-events (loop while (input-pending-p)
> collect (read-event nil nil 0.1))))
> (cond ((equal (subseq unread-events -4)
> '(21 54 54 54)) ; C-u 6 6 6
> (debug nil 'my-break))
> (t
> (discard-input)
> (let ((debug-on-quit nil))
> (signal 'quit nil))))))
> (t
> (apply #'debug args))))
That works great! Thanks! It's now in my .emacs.
I think Emacs 24.2 should have something along these lines switched on
by default. I think it would make a lot of bug reporting easier, since
it would enable users to get a backtrace on hangs very easily.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/