emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104652: Handle old buffer display op


From: martin rudalics
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104652: Handle old buffer display options more faithfully.
Date: Tue, 21 Jun 2011 10:29:43 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104652
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Tue 2011-06-21 10:29:43 +0200
message:
  Handle old buffer display options more faithfully.
  
  * window.el (display-buffer-alist): In default value do not
  enforce searching a window on any but the selected frame.
  Reported by Katsumi Yamaoka <address@hidden>.
  (display-buffer-select-window): Remove function.
  (display-buffer-in-window): When a window on another frame gets
  reused, do not select it any more but just raise its frame if
  necessary (Bug#8851) and (Bug#8856).
  (display-buffer-normalize-options): Handle pop-up-frames related
  options more faithfully.
  (pop-to-buffer): Don't rely on `display-buffer' selecting the
  window if it is on another frame.
modified:
  lisp/ChangeLog
  lisp/window.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-06-21 03:16:02 +0000
+++ b/lisp/ChangeLog    2011-06-21 08:29:43 +0000
@@ -1,3 +1,17 @@
+2011-06-21  Martin Rudalics  <address@hidden>
+
+       * window.el (display-buffer-alist): In default value do not
+       enforce searching a window on any but the selected frame.
+       Reported by Katsumi Yamaoka <address@hidden>.
+       (display-buffer-select-window): Remove function.
+       (display-buffer-in-window): When a window on another frame gets
+       reused, do not select it any more but just raise its frame if
+       necessary (Bug#8851) and (Bug#8856).
+       (display-buffer-normalize-options): Handle pop-up-frames related
+       options more faithfully.
+       (pop-to-buffer): Don't rely on `display-buffer' selecting the
+       window if it is on another frame.
+
 2011-06-21  Vincent Belaïche  <address@hidden>
 
        * play/5x5.el (5x5-solve-rotate-left, 5x5-solve-rotate-right):
@@ -75,14 +89,6 @@
 
        * net/rcirc.el: Delete trailing whitespaces once and for all.
 
-2011-06-20  Martin Rudalics  <address@hidden>
-
-       * window.el (get-window-with-predicate): Start scanning with
-       window following selected window to restore Emacs 23 behavior.
-       Clarify doc-string.
-       (get-buffer-window-list): Start scanning with selected window to
-       restore Emacs 23 behavior.  Clarify doc-string.
-
 2011-06-20  Daniel Colascione  <address@hidden>
 
        * emacs-lisp/syntax.el (syntax-ppss): Further improve docstring.

=== modified file 'lisp/window.el'
--- a/lisp/window.el    2011-06-20 08:41:57 +0000
+++ b/lisp/window.el    2011-06-21 08:29:43 +0000
@@ -3862,8 +3862,8 @@
 
 (defcustom display-buffer-alist
   '((((regexp . ".*"))
-     ;; Reuse window showing same buffer.
-     reuse-window (reuse-window nil same visible)
+     ;; Reuse window showing same buffer on same frame.
+     reuse-window (reuse-window nil same nil)
      ;; Pop up window.
      pop-up-window
      ;; Split largest or lru window.
@@ -4723,22 +4723,6 @@
      ((functionp set-width)
       (ignore-errors (funcall set-width window))))))
 
-;; We have to work around the deficiency that the command loop does not
-;; preserve the selected window when it is on a frame that hasn't been
-;; raised or given input focus.  So we have to (1) select the window
-;; used for displaying a buffer and (2) raise its frame if necessary,
-;; thus defeating one primary principle of `display-buffer' namely to
-;; _not_ select the window chosen for displaying the buffer :-(
-(defun display-buffer-select-window (window &optional norecord)
-  "Select WINDOW and raise its frame if necessary."
-  (let ((old-frame (selected-frame))
-       (new-frame (window-frame window)))
-    ;; Select WINDOW _before_ raising the frame to assure that the mouse
-    ;; cursor moves into the correct window.
-    (select-window window norecord)
-    (unless (eq old-frame new-frame)
-      (select-frame-set-input-focus new-frame))))
-
 (defun display-buffer-in-window (buffer window specifiers)
   "Display BUFFER in WINDOW and raise its frame if needed.
 WINDOW must be a live window and defaults to the selected one.
@@ -4759,8 +4743,16 @@
       (set-window-dedicated-p window dedicated))
     (when no-other-window
       (set-window-parameter window 'no-other-window t))
-    (unless (eq old-frame new-frame)
-      (display-buffer-select-window window))
+    (unless (or (eq old-frame new-frame)
+               (not (frame-visible-p new-frame))
+               ;; Assume the selected frame is already visible enough.
+               (eq new-frame (selected-frame))
+               ;; Assume the frame from which we invoked the minibuffer
+               ;; is visible.
+               (and (minibuffer-window-active-p (selected-window))
+                    (eq new-frame
+                        (window-frame (minibuffer-selected-window)))))
+      (raise-frame new-frame))
     ;; Return window.
     window))
 
@@ -5357,11 +5349,14 @@
 BUFFER-OR-NAME is the buffer to display.  This routine provides a
 compatibility layer for the now obsolete Emacs 23 buffer display
 options."
-  (let* ((buffer (normalize-live-buffer buffer-or-name))
-        (buffer-name (buffer-name buffer))
-        specifiers)
-    ;; Disable warnings, there are too many obsolete options here.
-    (with-no-warnings
+  (with-no-warnings
+    (let* ((buffer (normalize-live-buffer buffer-or-name))
+          (buffer-name (buffer-name buffer))
+          (use-pop-up-frames
+           (or (and (eq pop-up-frames 'graphic-only)
+                    (display-graphic-p))
+               pop-up-frames))
+          specifiers)
       ;; `even-window-heights', unless nil or unset.
       (unless (memq even-window-heights '(nil unset))
        (setq specifiers
@@ -5408,10 +5403,8 @@
                            (cons 'largest fun) (cons 'lru fun))
                      specifiers))))
 
-      ;; `pop-up-frame' group.  Add things if `pop-up-frames' is non-nil
-      ;; (we ignore the problem that callers usually don't care about
-      ;; graphic-only).
-      (when pop-up-frames
+      ;; `pop-up-frame' group.
+      (when use-pop-up-frames
        ;; `pop-up-frame-function'.  If `pop-up-frame-function' uses the
        ;; now obsolete `pop-up-frame-alist' it will continue to do so.
        (setq specifiers
@@ -5419,7 +5412,16 @@
                    specifiers))
        ;; `pop-up-frame'
        (setq specifiers
-             (cons (list 'pop-up-frame pop-up-frames) specifiers)))
+             (cons (list 'pop-up-frame t) specifiers)))
+
+      ;; `pop-up-windows' and `use-pop-up-frames' both nil means means
+      ;; we are supposed to reuse any window on the same frame (unless
+      ;; we find one showing the same buffer already).
+      (unless (or pop-up-windows use-pop-up-frames)
+       ;; `reuse-window' showing any buffer on same frame.
+       (setq specifiers
+             (cons (list 'reuse-window nil nil nil)
+                   specifiers)))
 
       ;; `special-display-p' group.
       (when special-display-function
@@ -5432,6 +5434,19 @@
                              (when (listp pars) pars))
                        specifiers)))))
 
+      ;; `pop-up-frames', `display-buffer-reuse-frames', and
+      ;; `last-nonminibuffer-frame' set means search for a window shoing
+      ;; the same buffer of another frame.
+      (let ((frames (or (last-nonminibuffer-frame)
+                       (and (or use-pop-up-frames
+                                display-buffer-reuse-frames)
+                            ;; All visible or iconfied frames.
+                            0))))
+       (when frames
+         (setq specifiers
+               (cons (list 'reuse-window 'other 'same frames)
+                     specifiers))))
+
       ;; `same-window-p' group.
       (when (same-window-p buffer-name)
        ;; Try to reuse the same (selected) window.
@@ -5439,25 +5454,9 @@
              (cons (list 'reuse-window 'same nil nil)
                    specifiers)))
 
-      ;; `pop-up-windows' and `pop-up-frames' both nil means means we
-      ;; are supposed to reuse any window (unless we find one showing
-      ;; the same buffer already).
-      (unless (or pop-up-windows pop-up-frames)
-       ;; `reuse-window' showing any buffer on same frame.
-       (setq specifiers
-             (cons (list 'reuse-window nil nil nil)
-                   specifiers)))
-
-      ;; `display-buffer-reuse-frames' or `pop-up-frames' non-nil means
-      ;; we are supposed to reuse a window showing the same buffer on
-      ;; another frame.
-      (when (or display-buffer-reuse-frames pop-up-frames)
-       ;; `reuse-window' showing same buffer on visible frame.
-       (setq specifiers
-             (cons (list 'reuse-window nil 'same 0) specifiers)))
-
       ;; Prepend "reuse window on same frame if showing the buffer
-      ;; already" specifier.
+      ;; already" specifier.  It will be overriden by the application
+      ;; supplied 'other-window specifier.
       (setq specifiers (cons (list 'reuse-window nil 'same nil)
                             specifiers))
 
@@ -5761,11 +5760,21 @@
 additional information."
   (interactive "BPop to buffer:\nP")
   (let ((buffer (normalize-buffer-to-display buffer-or-name))
-       window)
+       (old-window (selected-window))
+       (old-frame (selected-frame))
+       new-window new-frame)
     (set-buffer buffer)
-    (when (setq window (display-buffer buffer specifiers label))
-      (select-window window norecord)
-      buffer)))
+    (setq new-window (display-buffer buffer specifiers label))
+    (unless (eq new-window old-window)
+      ;; `display-buffer' has chosen another window, select it.
+      (select-window new-window norecord)
+      (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)))
+
+    buffer))
 
 (defsubst pop-to-buffer-same-window (&optional buffer-or-name norecord label)
   "Pop to buffer specified by BUFFER-OR-NAME in the selected window.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]