diff options
| author | martin rudalics | 2023-02-12 10:33:11 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2023-02-18 19:24:59 +0200 |
| commit | 9f508cef85df64ccbafada477bbb17a8439bc839 (patch) | |
| tree | a5b47bb28e0906bdf4c4e237f77aa4a631700458 /src/window.c | |
| parent | 5190ea6259a5fd13ba5e87b92b20f450658cf532 (diff) | |
| download | emacs-9f508cef85df64ccbafada477bbb17a8439bc839.tar.gz emacs-9f508cef85df64ccbafada477bbb17a8439bc839.zip | |
Fix 'display-buffer-use-least-recent-window'
* src/window.c (Fwindow_use_time): Doc fix.
(Fwindow_bump_use_time): Bump use time of the seleceted window as
well. Doc fix.
* lisp/window.el (display-buffer-avoid-small-windows): Remove.
All users changed.
(window--display-buffer): Bump window use time when requested.
(display-buffer--lru-window): New function.
(display-buffer-use-some-window): Use it.
(display-buffer-use-least-recent-window): Rewrite and enhance doc
string.
* doc/lispref/windows.texi (Selecting Windows)
(Buffer Display Action Functions, Buffer Display Action Alists)
(The Zen of Buffer Display): Improve and update documentation of
window selection and display facilities.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/window.c b/src/window.c index 6201a6f4a36..a94e1d611c7 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -762,10 +762,15 @@ future use. */) | |||
| 762 | 762 | ||
| 763 | DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, | 763 | DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, |
| 764 | doc: /* Return the use time of window WINDOW. | 764 | doc: /* Return the use time of window WINDOW. |
| 765 | WINDOW must be a live window and defaults to the selected one. | 765 | WINDOW must specify a live window and defaults to the selected one. |
| 766 | The window with the highest use time is the most recently selected | 766 | |
| 767 | one. The window with the lowest use time is the least recently | 767 | The window with the highest use time is usually the one most recently |
| 768 | selected one. */) | 768 | selected by calling `select-window' with NORECORD nil. The window with |
| 769 | the lowest use time is usually the least recently selected one chosen in | ||
| 770 | such a way. | ||
| 771 | |||
| 772 | Note that the use time of a window can be also changed by calling | ||
| 773 | `window-bump-use-time' for that window. */) | ||
| 769 | (Lisp_Object window) | 774 | (Lisp_Object window) |
| 770 | { | 775 | { |
| 771 | return make_fixnum (decode_live_window (window)->use_time); | 776 | return make_fixnum (decode_live_window (window)->use_time); |
| @@ -773,15 +778,27 @@ selected one. */) | |||
| 773 | 778 | ||
| 774 | DEFUN ("window-bump-use-time", Fwindow_bump_use_time, | 779 | DEFUN ("window-bump-use-time", Fwindow_bump_use_time, |
| 775 | Swindow_bump_use_time, 0, 1, 0, | 780 | Swindow_bump_use_time, 0, 1, 0, |
| 776 | doc: /* Mark WINDOW as having been most recently used. | 781 | doc: /* Mark WINDOW as second most recently used. |
| 777 | WINDOW must be a live window and defaults to the selected one. */) | 782 | WINDOW must specify a live window. |
| 783 | |||
| 784 | If WINDOW is not selected and the selected window has the highest use | ||
| 785 | time of all windows, set the use time of WINDOW to that of the selected | ||
| 786 | window, increase the use time of the selected window by one and return | ||
| 787 | the new use time of WINDOW. Otherwise, do nothing and return nil. */) | ||
| 778 | (Lisp_Object window) | 788 | (Lisp_Object window) |
| 779 | { | 789 | { |
| 780 | struct window *w = decode_live_window (window); | 790 | struct window *w = decode_live_window (window); |
| 791 | struct window *sw = XWINDOW (selected_window); | ||
| 781 | 792 | ||
| 782 | w->use_time = ++window_select_count; | 793 | if (w != sw && sw->use_time == window_select_count) |
| 794 | { | ||
| 795 | w->use_time = window_select_count; | ||
| 796 | sw->use_time = ++window_select_count; | ||
| 783 | 797 | ||
| 784 | return Qnil; | 798 | return make_fixnum (w->use_time); |
| 799 | } | ||
| 800 | else | ||
| 801 | return Qnil; | ||
| 785 | } | 802 | } |
| 786 | 803 | ||
| 787 | DEFUN ("window-pixel-width", Fwindow_pixel_width, Swindow_pixel_width, 0, 1, 0, | 804 | DEFUN ("window-pixel-width", Fwindow_pixel_width, Swindow_pixel_width, 0, 1, 0, |