From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: new buffer display action: display-buffer-reuse-frame Date: Sun, 26 Jul 2015 14:48:40 -0500 Message-ID: <86d1zebsyv.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1437940153 30027 80.91.229.3 (26 Jul 2015 19:49:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Jul 2015 19:49:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 26 21:49:03 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZJRuv-0000Cl-LK for ged-emacs-devel@m.gmane.org; Sun, 26 Jul 2015 21:49:01 +0200 Original-Received: from localhost ([::1]:50822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJRuu-0003VH-OD for ged-emacs-devel@m.gmane.org; Sun, 26 Jul 2015 15:49:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJRuq-0003V9-TL for emacs-devel@gnu.org; Sun, 26 Jul 2015 15:48:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJRul-0002Uc-Tt for emacs-devel@gnu.org; Sun, 26 Jul 2015 15:48:56 -0400 Original-Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:45694) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ZJRul-0002Pg-Ir for emacs-devel@gnu.org; Sun, 26 Jul 2015 15:48:51 -0400 Original-Received: (qmail 6467 invoked by uid 0); 26 Jul 2015 19:48:46 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy1.mail.unifiedlayer.com with SMTP; 26 Jul 2015 19:48:46 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw3 with id xDoi1q00n2UdiVW01DolHi; Sun, 26 Jul 2015 19:48:45 -0600 X-Authority-Analysis: v=2.1 cv=Qc314Krv c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=9i_RQKNPAAAA:8 a=y7kgw_RnJtkA:10 a=hEr_IkYJT6EA:10 a=x_XPkuGwIRMA:10 a=zOBTXjUuO1YA:10 a=OVF_lhN58Y2WQiLh194A:9 Original-Received: from [76.218.37.33] (port=56476 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1ZJRud-0002rl-9Z for emacs-devel@gnu.org; Sun, 26 Jul 2015 13:48:43 -0600 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 76.218.37.33 authed with stephen_leake@stephe-leake.org} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.25.95 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:188101 Archived-At: I'd like to add display-buffer-reuse-frame to window.el: (defun display-buffer-reuse-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)))) )) This is an alternative to display-buffer-pop-up-frame. I have a couple of use cases for it, both based on the premise that there are normally two Emacs frames open. This allows other applications to temporarily cover one of the frames while still allowing Emacs to be in the foreground. It also provides another level of buffer placement control. - Using ediff to review a file for a commit. There are now three frames; the ediff control frame, the frame containing the old and current file versions under ediff control, and another frame. The user wants to put the log edit buffer in the other frame; they specify display-buffer-reuse-frame as the action, with a frame predicate that excludes the two ediff frames. - User would like to move a buffer to the other frame. For instance, they just used M-. to find the definition of an elisp function, and they'd like to return to the use of the function, while keeping the definition visible. They specify display-buffer-reuse-frame as the action. Thoughts? -- -- Stephe