* window.el (pop-to-buffer): Ensure right window is selected if we chose another...
authorChong Yidong <cyd@stupidchicken.com>
Fri, 23 Sep 2011 01:42:40 +0000 (21:42 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Fri, 23 Sep 2011 01:42:40 +0000 (21:42 -0400)
Otherwise, C-x 5 b might not select the right window if reusing a
window on another frame.

lisp/ChangeLog
lisp/window.el

index cfa2035db912a618f85c8e020aac8c3c845ae168..ceef0b7f9b23e7cd87f1cff07a091f8fe30d4135 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-23  Chong Yidong  <cyd@stupidchicken.com>
+
+       * window.el (pop-to-buffer): Ensure right window is selected if we
+       chose another frame.
+
 2011-09-22  Eli Zaretskii  <eliz@gnu.org>
 
        * simple.el (what-cursor-position): Use get-char-property-change
index fb74c4392470dc66f4a2ad972f8f096327c2bf37..8a72c28f894b035b3d04c303c6bbae3dca80c135 100644 (file)
@@ -4853,12 +4853,11 @@ at the front of the list of recently selected ones."
         (old-frame (selected-frame))
         (window (display-buffer buffer action))
         (frame (window-frame window)))
-    (if (eq frame old-frame)
-       ;; Make sure new window is selected (Bug#8615), (Bug#6954).
-       (select-window window norecord)
-      ;; If `display-buffer' has chosen another frame, make sure it
-      ;; gets input focus.
+    ;; If we chose another frame, make sure it gets input focus.
+    (unless (eq frame old-frame)
       (select-frame-set-input-focus frame norecord))
+    ;; Make sure new window is selected (Bug#8615), (Bug#6954).
+    (select-window window norecord)
     buffer))
 
 (defun pop-to-buffer-same-window (buffer &optional norecord)