]> git.eshelyaron.com Git - emacs.git/commitdiff
(display-buffer): Fix handling of not-this-window
authorMartin Rudalics <rudalics@gmx.at>
Thu, 27 Nov 2008 13:20:15 +0000 (13:20 +0000)
committerMartin Rudalics <rudalics@gmx.at>
Thu, 27 Nov 2008 13:20:15 +0000 (13:20 +0000)
argument.  (Bug#1415)

lisp/ChangeLog
lisp/window.el

index 774c3c62606a61f0a5a6d9442ff611151d3186c0..a9779c010f83545398bb54d95e3ada97bf0b64dd 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-27  Martin Rudalics  <rudalics@gmx.at>
+
+       * window.el (display-buffer): Fix handling of not-this-window
+       argument.  (Bug#1415)
+
 2008-11-27  Kenichi Handa  <handa@m17n.org>
 
        * international/characters.el: Set category 'C' to characters
index 02af7bd6c5459a1f5490bc3cc1937de8cf74d23e..6373185ffaa25d29e0fc251ad8005c3ab0eaeafa 100644 (file)
@@ -1038,14 +1038,31 @@ consider all visible or iconified frames."
                     (window--try-to-split-window
                      (get-lru-window frame-to-use t))))
           (window--display-buffer-2 buffer window-to-use)))
-     ((setq window-to-use
-           ;; Reuse an existing window.
-           (or (get-lru-window frame-to-use)
-               (get-buffer-window buffer 'visible)
-               (get-largest-window 'visible nil)
-               (get-buffer-window buffer 0)
-               (get-largest-window 0 nil)
-               (frame-selected-window (funcall pop-up-frame-function))))
+     ((let ((window-to-undedicate
+            ;; When NOT-THIS-WINDOW is non-nil, temporarily dedicate
+            ;; the selected window to its buffer, to avoid that some of
+            ;; the `get-' routines below choose it.  (Bug#1415)
+            (and not-this-window (not (window-dedicated-p))
+                 (set-window-dedicated-p (selected-window) t)
+                 (selected-window))))
+       (unwind-protect
+           (setq window-to-use
+                 ;; Reuse an existing window.
+                 (or (get-lru-window frame-to-use)
+                     (let ((window (get-buffer-window buffer 'visible)))
+                       (unless (and not-this-window
+                                    (eq window (selected-window)))
+                         window))
+                     (get-largest-window 'visible)
+                     (let ((window (get-buffer-window buffer 0)))
+                       (unless (and not-this-window
+                                    (eq window (selected-window)))
+                         window))
+                     (get-largest-window 0)
+                     (frame-selected-window (funcall pop-up-frame-function))))
+         (when (window-live-p window-to-undedicate)
+           ;; Restore dedicated status of selected window.
+           (set-window-dedicated-p window-to-undedicate nil))))
       (window--even-window-heights window-to-use)
       (window--display-buffer-2 buffer window-to-use)))))