diff options
| author | Lars Ingebrigtsen | 2021-01-07 16:35:48 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-01-07 16:35:48 +0100 |
| commit | 40a0f8a3a2ac790bb398c321e7eb6928da330511 (patch) | |
| tree | f3afec5a6136ff483ca3c6e7e1427b2c2757eb6d /lisp | |
| parent | 0e6b74d2047452bb1fc3285921465132aeda0cb7 (diff) | |
| download | emacs-40a0f8a3a2ac790bb398c321e7eb6928da330511.tar.gz emacs-40a0f8a3a2ac790bb398c321e7eb6928da330511.zip | |
Add a display-buffer window selection function that's more like XEmacs
* doc/lispref/windows.texi (Buffer Display Action Functions):
Document it.
* lisp/window.el (display-buffer--action-function-custom-type): Add.
(display-buffer): Mention it.
(display-buffer-use-least-recent-window): New function (bug#45688).
* src/window.c (Fwindow_bump_use_time): New function.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/window.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/window.el b/lisp/window.el index c54a0db211e..37e1800ad11 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -7243,6 +7243,7 @@ The actual non-nil value of this variable will be copied to the | |||
| 7243 | (const display-buffer-below-selected) | 7243 | (const display-buffer-below-selected) |
| 7244 | (const display-buffer-at-bottom) | 7244 | (const display-buffer-at-bottom) |
| 7245 | (const display-buffer-in-previous-window) | 7245 | (const display-buffer-in-previous-window) |
| 7246 | (const display-buffer-use-least-recent-window) | ||
| 7246 | (const display-buffer-use-some-window) | 7247 | (const display-buffer-use-some-window) |
| 7247 | (const display-buffer-use-some-frame) | 7248 | (const display-buffer-use-some-frame) |
| 7248 | (function :tag "Other function")) | 7249 | (function :tag "Other function")) |
| @@ -7387,6 +7388,8 @@ to a list containing one of these \"action\" functions: | |||
| 7387 | `display-buffer-in-previous-window' -- Use a window that did | 7388 | `display-buffer-in-previous-window' -- Use a window that did |
| 7388 | show the buffer before. | 7389 | show the buffer before. |
| 7389 | `display-buffer-use-some-window' -- Use some existing window. | 7390 | `display-buffer-use-some-window' -- Use some existing window. |
| 7391 | `display-buffer-use-least-recent-window' -- Try to avoid re-using | ||
| 7392 | windows that have recently been switched to. | ||
| 7390 | `display-buffer-pop-up-window' -- Pop up a new window. | 7393 | `display-buffer-pop-up-window' -- Pop up a new window. |
| 7391 | `display-buffer-below-selected' -- Use or pop up a window below | 7394 | `display-buffer-below-selected' -- Use or pop up a window below |
| 7392 | the selected one. | 7395 | the selected one. |
| @@ -8256,6 +8259,16 @@ indirectly called by the latter." | |||
| 8256 | (when (setq window (or best-window second-best-window)) | 8259 | (when (setq window (or best-window second-best-window)) |
| 8257 | (window--display-buffer buffer window 'reuse alist)))) | 8260 | (window--display-buffer buffer window 'reuse alist)))) |
| 8258 | 8261 | ||
| 8262 | (defun display-buffer-use-least-recent-window (buffer alist) | ||
| 8263 | "Display BUFFER in an existing window, but that hasn't been used lately. | ||
| 8264 | This `display-buffer' action function is like | ||
| 8265 | `display-buffer-use-some-window', but will cycle through windows | ||
| 8266 | when displaying buffers repeatedly, and if there's only a single | ||
| 8267 | window, it will split the window." | ||
| 8268 | (when-let ((window (display-buffer-use-some-window | ||
| 8269 | buffer (cons (cons 'inhibit-same-window t) alist)))) | ||
| 8270 | (window-bump-use-time window))) | ||
| 8271 | |||
| 8259 | (defun display-buffer-use-some-window (buffer alist) | 8272 | (defun display-buffer-use-some-window (buffer alist) |
| 8260 | "Display BUFFER in an existing window. | 8273 | "Display BUFFER in an existing window. |
| 8261 | Search for a usable window, set that window to the buffer, and | 8274 | Search for a usable window, set that window to the buffer, and |