- (unless noninteractive
- (message "Entering debugger..."))
- (let (debugger-value
- (debug-on-error nil)
- (debug-on-quit nil)
- (debugger-buffer (let ((default-major-mode 'fundamental-mode))
- (get-buffer-create "*Backtrace*")))
- (debugger-old-buffer (current-buffer))
- (debugger-step-after-exit nil)
- ;; Don't keep reading from an executing kbd macro!
- (executing-kbd-macro nil)
- ;; Save the outer values of these vars for the `e' command
- ;; before we replace the values.
- (debugger-outer-match-data (match-data))
- (debugger-outer-load-read-function load-read-function)
- (debugger-outer-overriding-local-map overriding-local-map)
- (debugger-outer-overriding-terminal-local-map
- overriding-terminal-local-map)
- (debugger-outer-track-mouse track-mouse)
- (debugger-outer-last-command last-command)
- (debugger-outer-this-command this-command)
- (debugger-outer-unread-command-char unread-command-char)
- (debugger-outer-unread-command-events unread-command-events)
- (debugger-outer-unread-post-input-method-events
- unread-post-input-method-events)
- (debugger-outer-last-input-event last-input-event)
- (debugger-outer-last-command-event last-command-event)
- (debugger-outer-last-nonmenu-event last-nonmenu-event)
- (debugger-outer-last-event-frame last-event-frame)
- (debugger-outer-standard-input standard-input)
- (debugger-outer-standard-output standard-output)
- (debugger-outer-inhibit-redisplay inhibit-redisplay)
- (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
- ;; Set this instead of binding it, so that `q'
- ;; will not restore it.
- (setq overriding-terminal-local-map nil)
- ;; Don't let these magic variables affect the debugger itself.
- (let ((last-command nil) this-command track-mouse
- (unread-command-char -1) unread-command-events
- unread-post-input-method-events
- last-input-event last-command-event last-nonmenu-event
- last-event-frame
- overriding-local-map
- load-read-function
- ;; If we are inside a minibuffer, allow nesting
- ;; so that we don't get an error from the `e' command.
- (enable-recursive-minibuffers
- (or enable-recursive-minibuffers (> (minibuffer-depth) 0)))
- (standard-input t) (standard-output t)
- inhibit-redisplay
- (cursor-in-echo-area nil))
- (unwind-protect
- (save-excursion
- (save-window-excursion
- (pop-to-buffer debugger-buffer)
- (debugger-mode)
- (debugger-setup-buffer debugger-args)
- (when noninteractive
- ;; If the backtrace is long, save the beginning
- ;; and the end, but discard the middle.
- (when (> (count-lines (point-min) (point-max))
- debugger-batch-max-lines)
+ (if inhibit-redisplay
+ ;; Don't really try to enter debugger within an eval from redisplay.
+ debugger-value
+ (unless noninteractive
+ (message "Entering debugger..."))
+ (let (debugger-value
+ (debug-on-error nil)
+ (debug-on-quit nil)
+ (debugger-buffer (let ((default-major-mode 'fundamental-mode))
+ (get-buffer-create "*Backtrace*")))
+ (debugger-old-buffer (current-buffer))
+ (debugger-step-after-exit nil)
+ ;; Don't keep reading from an executing kbd macro!
+ (executing-kbd-macro nil)
+ ;; Save the outer values of these vars for the `e' command
+ ;; before we replace the values.
+ (debugger-outer-match-data (match-data))
+ (debugger-outer-load-read-function load-read-function)
+ (debugger-outer-overriding-local-map overriding-local-map)
+ (debugger-outer-overriding-terminal-local-map
+ overriding-terminal-local-map)
+ (debugger-outer-track-mouse track-mouse)
+ (debugger-outer-last-command last-command)
+ (debugger-outer-this-command this-command)
+ (debugger-outer-unread-command-char
+ (with-no-warnings unread-command-char))
+ (debugger-outer-unread-command-events unread-command-events)
+ (debugger-outer-unread-post-input-method-events
+ unread-post-input-method-events)
+ (debugger-outer-last-input-event last-input-event)
+ (debugger-outer-last-command-event last-command-event)
+ (debugger-outer-last-nonmenu-event last-nonmenu-event)
+ (debugger-outer-last-event-frame last-event-frame)
+ (debugger-outer-standard-input standard-input)
+ (debugger-outer-standard-output standard-output)
+ (debugger-outer-inhibit-redisplay inhibit-redisplay)
+ (debugger-outer-cursor-in-echo-area cursor-in-echo-area))
+ ;; Set this instead of binding it, so that `q'
+ ;; will not restore it.
+ (setq overriding-terminal-local-map nil)
+ ;; Don't let these magic variables affect the debugger itself.
+ (let ((last-command nil) this-command track-mouse
+ unread-command-events
+ unread-post-input-method-events
+ last-input-event last-command-event last-nonmenu-event
+ last-event-frame
+ overriding-local-map
+ load-read-function
+ ;; If we are inside a minibuffer, allow nesting
+ ;; so that we don't get an error from the `e' command.
+ (enable-recursive-minibuffers
+ (or enable-recursive-minibuffers (> (minibuffer-depth) 0)))
+ (standard-input t) (standard-output t)
+ inhibit-redisplay
+ (cursor-in-echo-area nil))
+ (unwind-protect
+ (save-excursion
+ (save-window-excursion
+ (with-no-warnings
+ (setq unread-command-char -1))
+ (pop-to-buffer debugger-buffer)
+ (debugger-mode)
+ (debugger-setup-buffer debugger-args)
+ (when noninteractive
+ ;; If the backtrace is long, save the beginning
+ ;; and the end, but discard the middle.
+ (when (> (count-lines (point-min) (point-max))
+ debugger-batch-max-lines)
+ (goto-char (point-min))
+ (forward-line (/ 2 debugger-batch-max-lines))
+ (let ((middlestart (point)))
+ (goto-char (point-max))
+ (forward-line (- (/ 2 debugger-batch-max-lines)
+ debugger-batch-max-lines))
+ (delete-region middlestart (point)))
+ (insert "...\n"))