Commit e227544d authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp/emacs-lisp/debug.el (debug): Save&restore not just the buffer's

content but also its previous major mode.
parent e8296fdc
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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment