aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/window.el
diff options
context:
space:
mode:
authorMartin Rudalics2012-09-08 15:28:11 +0200
committerMartin Rudalics2012-09-08 15:28:11 +0200
commitfa2bcf435d9774c0e8542ba36b11ef4722f9675c (patch)
treeae13b3c6076ec4c063e4ebaa5b093a2f56dc8a55 /lisp/window.el
parentaa7d57c5079024458c5e25cd5f304d1b967bcbe6 (diff)
downloademacs-fa2bcf435d9774c0e8542ba36b11ef4722f9675c.tar.gz
emacs-fa2bcf435d9774c0e8542ba36b11ef4722f9675c.zip
Fix handling of debugger window. (Bug#8789)
* window.el (display-buffer-in-previous-window): New buffer display action function. * emacs-lisp/debug.el (debugger-bury-or-kill): New option. (debugger-previous-window): New variable. (debug): Rewrite using display-buffer-in-previous-window, quit-restore-window and debugger-bury-or-kill. (Bug#8789)
Diffstat (limited to 'lisp/window.el')
-rw-r--r--lisp/window.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/lisp/window.el b/lisp/window.el
index 0e03268029c..b071a8e9c50 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5521,6 +5521,62 @@ the selected one."
5521 (window--display-buffer 5521 (window--display-buffer
5522 buffer window 'reuse display-buffer-mark-dedicated))))) 5522 buffer window 'reuse display-buffer-mark-dedicated)))))
5523 5523
5524(defun display-buffer-in-previous-window (buffer alist)
5525 "Display BUFFER in a window previously showing it.
5526If ALIST has a non-nil `inhibit-same-window' entry, the selected
5527window is not eligible for reuse.
5528
5529If ALIST contains a `reusable-frames' entry, its value determines
5530which frames to search for a reusable window:
5531 nil -- the selected frame (actually the last non-minibuffer frame)
5532 A frame -- just that frame
5533 `visible' -- all visible frames
5534 0 -- all frames on the current terminal
5535 t -- all frames.
5536
5537If ALIST contains no `reusable-frames' entry, search just the
5538selected frame if `display-buffer-reuse-frames' and
5539`pop-up-frames' are both nil; search all frames on the current
5540terminal if either of those variables is non-nil.
5541
5542If ALIST has a `previous-window' entry, the window specified by
5543that entry will override any other window found by the methods
5544above, even if that window never showed BUFFER before."
5545 (let* ((alist-entry (assq 'reusable-frames alist))
5546 (inhibit-same-window
5547 (cdr (assq 'inhibit-same-window alist)))
5548 (frames (cond
5549 (alist-entry (cdr alist-entry))
5550 ((if (eq pop-up-frames 'graphic-only)
5551 (display-graphic-p)
5552 pop-up-frames)
5553 0)
5554 (display-buffer-reuse-frames 0)
5555 (t (last-nonminibuffer-frame))))
5556 entry best-window second-best-window window)
5557 ;; Scan windows whether they have shown the buffer recently.
5558 (catch 'best
5559 (dolist (window (window-list-1 (frame-first-window) 'nomini frames))
5560 (when (and (assq buffer (window-prev-buffers window))
5561 (not (window-dedicated-p window)))
5562 (if (eq window (selected-window))
5563 (unless inhibit-same-window
5564 (setq second-best-window window))
5565 (setq best-window window)
5566 (throw 'best t)))))
5567 ;; When ALIST has a `previous-window' entry, that entry may override
5568 ;; anything we found so far.
5569 (when (and (setq window (cdr (assq 'previous-window alist)))
5570 (window-live-p window)
5571 (not (window-dedicated-p window)))
5572 (if (eq window (selected-window))
5573 (unless inhibit-same-window
5574 (setq second-best-window window))
5575 (setq best-window window)))
5576 ;; Return best or second best window found.
5577 (when (setq window (or best-window second-best-window))
5578 (window--display-buffer buffer window 'reuse))))
5579
5524(defun display-buffer-use-some-window (buffer alist) 5580(defun display-buffer-use-some-window (buffer alist)
5525 "Display BUFFER in an existing window. 5581 "Display BUFFER in an existing window.
5526Search for a usable window, set that window to the buffer, and 5582Search for a usable window, set that window to the buffer, and