diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-05-31 12:41:14 -0300 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-05-31 12:41:14 -0300 |
commit | e227544d7b1e5e22923796929389f4c9bcab44e0 (patch) | |
tree | b966cb145c2c95e979514ac456ec59d2f720cbb3 /lisp | |
parent | e8296fdc980f927e4e534dc62ce4f436fdf3a779 (diff) | |
download | emacs-e227544d7b1e5e22923796929389f4c9bcab44e0.tar.gz |
* lisp/emacs-lisp/debug.el (debug): Save&restore not just the buffer's
content but also its previous major mode.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/emacs-lisp/debug.el | 21 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e6fdbd2372c..0070f3a3945 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-05-31 Stefan Monnier <monnier@iro.umontreal.ca> + + * emacs-lisp/debug.el (debug): Save&restore not just the buffer's + content but also its previous major mode. + 2011-05-31 Helmut Eller <eller.helmut@gmail.com> * debug.el (debug): Restore the previous content of the diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 4a43f59c9e2..28962595ace 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -118,9 +118,12 @@ first will be printed into the backtrace buffer." (let (debugger-value (debug-on-error nil) (debug-on-quit nil) + (debugger-previous-state + (if (get-buffer "*Backtrace*") + (with-current-buffer (get-buffer "*Backtrace*") + (list major-mode (buffer-string))))) (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! @@ -182,7 +185,6 @@ first will be printed into the backtrace buffer." (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 @@ -216,9 +218,6 @@ first will be printed into the backtrace buffer." ;; recreate it every time the debugger stops, so instead we'll ;; erase it (and maybe hide it) but keep it alive. (with-current-buffer debugger-buffer - (erase-buffer) - (insert debugger-previous-contents) - (fundamental-mode) (with-selected-window (get-buffer-window debugger-buffer 0) (when (and (window-dedicated-p (selected-window)) (not debugger-will-be-back)) @@ -235,7 +234,17 @@ first will be printed into the backtrace buffer." ;; to be left at the top-level, still working on how ;; best to do that. (bury-buffer)))) - (kill-buffer debugger-buffer)) + (unless debugger-previous-state + (kill-buffer debugger-buffer))) + ;; Restore the previous state of the debugger-buffer, in case we were + ;; in a recursive invocation of the debugger. + (when (and debugger-previous-state + (buffer-live-p debugger-buffer)) + (with-current-buffer debugger-buffer + (let ((inhibit-read-only t)) + (erase-buffer) + (insert (nth 1 debugger-previous-state)) + (funcall (nth 0 debugger-previous-state))))) (with-timeout-unsuspend debugger-with-timeout-suspend) (set-match-data debugger-outer-match-data))) ;; Put into effect the modified values of these variables |