emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging functions with lexical-binding


From: Helmut Eller
Subject: Re: Debugging functions with lexical-binding
Date: Tue, 31 May 2011 09:11:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

* Stefan Monnier [2011-05-30 04:13] writes:

>> What are the commands to inspect local variables of lexical functions?
>
> M-x esp RET

That's too cryptic for me.  What do you mean?

>> Pressing C-M-c reduces one level of recursive edit but puts the
>> *Backtrace* buffer in fundamental-mode which is IMO also wrong.]
>
> Yup, the *Backtrace* buffer's content and major-mode are not properly
> saved&restored upon entry to and exit from the debugger.  Patch welcome,

Below is a simple patch.  It only restores the content but not buffer
local variables.

Helmut

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2011-05-30 12:23:56 +0000
+++ lisp/ChangeLog      2011-05-31 07:08:41 +0000
@@ -1,3 +1,11 @@
+2011-05-31  Helmut Eller  <address@hidden>
+
+       Try to deal with recursive debuggers and C-M-c.
+
+       * debug.el (debug): Restore the previous content of the
+       *Backtrace* buffer when we exit with C-M-c.  Restoring buffer
+       local variables would be annoyingly difficult.
+
 2011-05-30  Leo Liu  <address@hidden>
 
        * net/rcirc.el (rcirc-debug-buffer): Use visible buffer name.

=== modified file 'lisp/emacs-lisp/debug.el'
--- lisp/emacs-lisp/debug.el    2011-03-20 03:53:45 +0000
+++ lisp/emacs-lisp/debug.el    2011-05-31 06:45:28 +0000
@@ -120,6 +120,7 @@
          (debug-on-quit nil)
          (debugger-buffer (get-buffer-create "*Backtrace*"))
          (debugger-old-buffer (current-buffer))
+         (debugger-previous-contents nil)
          (debugger-step-after-exit nil)
           (debugger-will-be-back nil)
          ;; Don't keep reading from an executing kbd macro!
@@ -181,6 +182,7 @@
                  (when (eq 'lambda (car-safe (cadr (backtrace-frame 4))))
                    (backtrace-debug 5 t)))
                 (pop-to-buffer debugger-buffer)
+               (setq debugger-previous-contents (buffer-string))
                (debugger-mode)
                (debugger-setup-buffer debugger-args)
                (when noninteractive
@@ -215,7 +217,7 @@
              ;; erase it (and maybe hide it) but keep it alive.
              (with-current-buffer debugger-buffer
                (erase-buffer)
-               (fundamental-mode)
+               (insert debugger-previous-contents)
                (with-selected-window (get-buffer-window debugger-buffer 0)
                   (when (and (window-dedicated-p (selected-window))
                              (not debugger-will-be-back))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]