aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics <[email protected]>2008-09-11 06:39:30 +0000
committerMartin Rudalics <[email protected]>2008-09-11 06:39:30 +0000
commita4f41c95a90568777801885afa32232ec277820d (patch)
tree76720dccf5a132d72766022bf755596da67492e1
parent6f3122a737cddf4b9e4ea75364ca3c3e872b7024 (diff)
(pop-to-buffer): If the window for buffer-or-name is
not on the selected frame, raise that window's frame and give it input focus. (Bug#745)
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/window.el19
2 files changed, 23 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0726591ef5..838c9302e6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-11 Martin Rudalics <[email protected]>
+
+ * window.el (pop-to-buffer): If the window for buffer-or-name is
+ not on the selected frame, raise that window's frame and give it
+ input focus. (Bug#745)
+
2008-09-11 Glenn Morris <[email protected]>
* ido.el (ido-mode): Initialize with custom-initialize-default.
diff --git a/lisp/window.el b/lisp/window.el
index 6c3a8cfce0..8f20820874 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1029,6 +1029,9 @@ insist on finding another window even if the specified buffer is
already visible in the selected window, and ignore
`same-window-regexps' and `same-window-buffer-names'.
+If the window to show BUFFER-OR-NAME is not on the selected
+frame, raise that window's frame and give it input focus.
+
This function returns the buffer it switched to. This uses the
function `display-buffer' as a subroutine; see the documentation
of `display-buffer' for additional customization information.
@@ -1043,9 +1046,21 @@ at the front of the list of recently selected ones."
(or (get-buffer buffer-or-name)
(let ((buf (get-buffer-create buffer-or-name)))
(set-buffer-major-mode buf)
- buf)))))
+ buf))))
+ (old-window (selected-window))
+ (old-frame (selected-frame))
+ new-window new-frame)
(set-buffer buffer)
- (select-window (display-buffer buffer other-window) norecord)
+ (setq new-window (display-buffer buffer other-window) norecord)
+ (unless (eq new-window old-window)
+ ;; `display-buffer' has chosen another window.
+ (setq new-frame (window-frame new-window))
+ (unless (eq new-frame old-frame)
+ ;; `display-buffer' has chosen another frame, make sure it gets
+ ;; input focus and is risen.
+ (select-frame-set-input-focus new-frame))
+ ;; Make sure the window chosen by `display-buffer' gets selected.
+ (select-window new-window))
buffer))
;; I think this should be the default; I think people will prefer it--rms.