all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* new buffer display action: display-buffer-reuse-frame
@ 2015-07-26 19:48 Stephen Leake
  2015-07-27 16:03 ` martin rudalics
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Leake @ 2015-07-26 19:48 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-30 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-26 19:48 new buffer display action: display-buffer-reuse-frame Stephen Leake
2015-07-27 16:03 ` martin rudalics
2015-07-30  0:24   ` Stephen Leake
2015-07-30  6:00     ` martin rudalics
2015-07-30 15:24       ` Stephen Leake
2015-07-30 16:41         ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.