windows are dedicated to other buffers (@pxref{Dedicated Windows}).
@end defun
+@defun display-buffer-use-least-recent-window buffer alist
+This function is like @code{display-buffer-use-some-window}, but will
+not reuse the current window, and will use the least recently
+switched-to window.
+@end defun
+
@defun display-buffer-in-direction buffer alist
This function tries to display @var{buffer} at a location specified by
@var{alist}. For this purpose, @var{alist} should contain a
** Windows
++++
+*** New 'display-buffer' function 'display-buffer-use-least-recent-window'
+This is like 'display-buffer-use-some-window', but won't reuse the
+current window, and when called repeatedly will try not to reuse a
+previously selected window.
+
+*** New function 'window-bump-use-time'.
+This updates the use time of a window.
+
*** The key prefix 'C-x 4 1' displays next command buffer in the same window.
It's bound to the command 'same-window-prefix' that requests the buffer
of the next command to be displayed in the same window.
(const display-buffer-below-selected)
(const display-buffer-at-bottom)
(const display-buffer-in-previous-window)
+ (const display-buffer-use-least-recent-window)
(const display-buffer-use-some-window)
(const display-buffer-use-some-frame)
(function :tag "Other function"))
`display-buffer-in-previous-window' -- Use a window that did
show the buffer before.
`display-buffer-use-some-window' -- Use some existing window.
+ `display-buffer-use-least-recent-window' -- Try to avoid re-using
+ windows that have recently been switched to.
`display-buffer-pop-up-window' -- Pop up a new window.
`display-buffer-below-selected' -- Use or pop up a window below
the selected one.
(when (setq window (or best-window second-best-window))
(window--display-buffer buffer window 'reuse alist))))
+(defun display-buffer-use-least-recent-window (buffer alist)
+ "Display BUFFER in an existing window, but that hasn't been used lately.
+This `display-buffer' action function is like
+`display-buffer-use-some-window', but will cycle through windows
+when displaying buffers repeatedly, and if there's only a single
+window, it will split the window."
+ (when-let ((window (display-buffer-use-some-window
+ buffer (cons (cons 'inhibit-same-window t) alist))))
+ (window-bump-use-time window)))
+
(defun display-buffer-use-some-window (buffer alist)
"Display BUFFER in an existing window.
Search for a usable window, set that window to the buffer, and
return Qt;
return Qnil;
}
+
+DEFUN ("window-bump-use-time", Fwindow_bump_use_time,
+ Swindow_bump_use_time, 1, 1, 0,
+ doc: /* Mark WINDOW as having been recently used. */)
+ (Lisp_Object window)
+{
+ struct window *w = decode_valid_window (window);
+
+ w->use_time = ++window_select_count;
+ return Qnil;
+}
+
\f
static void init_window_once_for_pdumper (void);
defsubr (&Swindow_vscroll);
defsubr (&Sset_window_vscroll);
defsubr (&Scompare_window_configurations);
+ defsubr (&Swindow_bump_use_time);
defsubr (&Swindow_list);
defsubr (&Swindow_list_1);
defsubr (&Swindow_prev_buffers);