[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Random idea: Debugging `quit'
From: |
Helmut Eller |
Subject: |
Re: Random idea: Debugging `quit' |
Date: |
Sun, 11 Sep 2011 18:51:58 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
* Lars Magne Ingebrigtsen [2011-09-11 04:01] writes:
> If something hangs, then I'd really like to know where it hangs. So I
> always wish that I'd have been running with `debug-on-quit' set. But
> doing so is really annoying, since `C-g' is a natural thing to do in
> many circumstances.
>
> So wouldn't it be nice if we could say, for instance, `C-u C-g' to get a
> debugging `quit'? Or perhaps `C-u 6 6 6 C-g', or whatever deemed
> necessary to avoid annoying people...
Yes, that would be nice.
Not so nice, but kill -SIGUSR2 <emacs-pid> in shell tells Emacs to
enter the debugger.
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))))
Helmut