emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 72fea2f: Add display-buffer action display-buffer-u


From: Stephen Leake
Subject: [Emacs-diffs] master 72fea2f: Add display-buffer action display-buffer-use-some-frame
Date: Wed, 29 Jul 2015 23:41:45 +0000

branch: master
commit 72fea2fac543558cd2c4bd55e6f714f9f43efbc3
Author: Stephen Leake <address@hidden>
Commit: Stephen Leake <address@hidden>

    Add display-buffer action display-buffer-use-some-frame
    
    * lisp/window.el (display-buffer-use-some-frame): new
---
 lisp/window.el |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/lisp/window.el b/lisp/window.el
index f15dd9b..986c553 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6488,6 +6488,39 @@ its documentation for additional customization 
information."
 
 ;;; `display-buffer' action functions:
 
+(defun display-buffer-use-some-frame (buffer alist)
+  "Display BUFFER in an existing frame other than the current frame.
+If successful, return the window used; otherwise return nil.
+
+If ALIST has a non-nil `inhibit-switch-frame' entry, avoid
+raising the frame.
+
+If ALIST has a non-nil `pop-up-frame-parameters' entry, the
+corresponding value is an alist of frame parameters to give the
+new frame.
+
+If ALIST has a non-nil `frame-predicate' entry, the corresponding
+value is a function taking one argument (a frame), returning
+non-nil if the frame is a candidate."
+  (let* ((predicate (or (cdr (assoc 'frame-predicate alist))
+                        (lambda (frame)
+                          (and
+                           (not (eq frame (selected-frame)))
+                           (not (window-dedicated-p
+                                 (or
+                                  (get-lru-window frame)
+                                  (frame-first-window frame)))))
+                          )))
+         (frame (car (filtered-frame-list predicate)))
+         (window (and frame (get-lru-window frame))))
+    (when window
+      (prog1
+          (window--display-buffer
+           buffer window 'frame alist display-buffer-mark-dedicated)
+        (unless (cdr (assq 'inhibit-switch-frame alist))
+          (window--maybe-raise-frame frame))))
+    ))
+
 (defun display-buffer-same-window (buffer alist)
   "Display BUFFER in the selected window.
 This fails if ALIST has a non-nil `inhibit-same-window' entry, or



reply via email to

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