[Top][All Lists]

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

new buffer display action: display-buffer-reuse-frame

From: Stephen Leake
Subject: new buffer display action: display-buffer-reuse-frame
Date: Sun, 26 Jul 2015 14:48:40 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

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)
                           (not (eq frame (selected-frame)))
                           (not (window-dedicated-p
                                  (get-lru-window frame)
                                  (frame-first-window frame)))))
         (frame (car (filtered-frame-list predicate)))
         (window (and frame (get-lru-window frame))))

    (when window
           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

-- Stephe

reply via email to

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