# HG changeset patch # User Martin Rudalics # Date 1231095789 0 # Node ID 1c4c26872c5ca8cc20ffdb59f4531bf5cb20a5f7 # Parent 19c85c36798db5e98228e8975bf87ed427573b62 (display-buffer): When a buffer is displayed in the selected and some other window, and not-this-window is non-nil, try to return that other window instead of popping up a new frame. (Bug#30) diff -r 19c85c36798d -r 1c4c26872c5c lisp/ChangeLog --- a/lisp/ChangeLog Sun Jan 04 13:09:35 2009 +0000 +++ b/lisp/ChangeLog Sun Jan 04 19:03:09 2009 +0000 @@ -1,3 +1,10 @@ +2009-01-04 Martin Rudalics + + * window.el (display-buffer): When a buffer is displayed in the + selected and some other window, and not-this-window is non-nil, + try to return that other window instead of popping up a new + frame. (Bug#30) + 2009-01-04 Chong Yidong * simple.el (visual-line-mode-map): Remove M-[ and M-] bindings. diff -r 19c85c36798d -r 1c4c26872c5c lisp/window.el --- a/lisp/window.el Sun Jan 04 13:09:35 2009 +0000 +++ b/lisp/window.el Sun Jan 04 19:03:09 2009 +0000 @@ -1006,10 +1006,16 @@ (not (last-nonminibuffer-frame))) 0) (last-nonminibuffer-frame)))) - (and (setq window-to-use (get-buffer-window buffer frames)) - (or can-use-selected-window - (not (eq (selected-window) window-to-use))))) - ;; If the buffer is already displayed in some window use that. + (setq window-to-use + (catch 'found + ;; Search all visible and iconified frames for a window + ;; displaying BUFFER. Return the selected window only + ;; if can-use-selected-window says we may do so. + (dolist (window (get-buffer-window-list buffer 'nomini 0)) + (when (or can-use-selected-window + (not (eq (selected-window) window))) + (throw 'found window)))))) + ;; The buffer is already displayed in some window; use that. (window--display-buffer-1 window-to-use)) ((and special-display-function ;; `special-display-p' returns either t or a list of frame