diff options
| author | Martin Rudalics | 2018-12-08 09:37:40 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2018-12-08 09:37:40 +0100 |
| commit | d2b3a37886d97abdc10e16f6389200e8ad45dd7a (patch) | |
| tree | f1649e61eb920544548e52931803278ebef4addc /lisp | |
| parent | 1d676aabca4bdba6948fb7a9d875ba63b51aed63 (diff) | |
| download | emacs-d2b3a37886d97abdc10e16f6389200e8ad45dd7a.tar.gz emacs-d2b3a37886d97abdc10e16f6389200e8ad45dd7a.zip | |
New buffer display action alist entry 'window-min-height' (Bug#32825)
* lisp/window.el (display-buffer-below-selected): Handle
'window-min-height' action alist entry (Bug#32825).
* doc/lispref/windows.texi (Buffer Display Action Functions)
(Buffer Display Action Alists): Add documentation for
'window-min-height' action alist entries.
* etc/NEWS: Mention 'window-min-height' action alist entry.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/window.el | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/lisp/window.el b/lisp/window.el index a16ceb4eb99..25a599f91d2 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -7465,22 +7465,45 @@ If there is a window below the selected one and that window | |||
| 7465 | already displays BUFFER, use that window. Otherwise, try to | 7465 | already displays BUFFER, use that window. Otherwise, try to |
| 7466 | create a new window below the selected one and show BUFFER there. | 7466 | create a new window below the selected one and show BUFFER there. |
| 7467 | If that attempt fails as well and there is a non-dedicated window | 7467 | If that attempt fails as well and there is a non-dedicated window |
| 7468 | below the selected one, use that window." | 7468 | below the selected one, use that window. |
| 7469 | (let (window) | 7469 | |
| 7470 | If ALIST contains a 'window-min-height' entry, this function | ||
| 7471 | ensures that the window used is or can become at least as high as | ||
| 7472 | specified by that entry's value. Note that such an entry alone | ||
| 7473 | will not resize the window per se. In order to do that, ALIST | ||
| 7474 | must also contain a 'window-height' entry with the same value." | ||
| 7475 | (let ((min-height (cdr (assq 'window-min-height alist))) | ||
| 7476 | window) | ||
| 7470 | (or (and (setq window (window-in-direction 'below)) | 7477 | (or (and (setq window (window-in-direction 'below)) |
| 7471 | (eq buffer (window-buffer window)) | 7478 | (eq buffer (window-buffer window)) |
| 7479 | (or (not (numberp min-height)) | ||
| 7480 | (>= (window-height window) min-height) | ||
| 7481 | ;; 'window--display-buffer' can resize this window if | ||
| 7482 | ;; and only if it has a 'quit-restore' parameter | ||
| 7483 | ;; certifying that it always showed BUFFER before. | ||
| 7484 | (let ((height (window-height window)) | ||
| 7485 | (quit-restore (window-parameter window 'quit-restore))) | ||
| 7486 | (and quit-restore | ||
| 7487 | (eq (nth 1 quit-restore) 'window) | ||
| 7488 | (window-resizable-p window (- min-height height))))) | ||
| 7472 | (window--display-buffer buffer window 'reuse alist)) | 7489 | (window--display-buffer buffer window 'reuse alist)) |
| 7473 | (and (not (frame-parameter nil 'unsplittable)) | 7490 | (and (not (frame-parameter nil 'unsplittable)) |
| 7474 | (let ((split-height-threshold 0) | 7491 | (or (not (numberp min-height)) |
| 7492 | (window-sizable-p nil (- min-height))) | ||
| 7493 | (let ((split-height-threshold 0) | ||
| 7475 | split-width-threshold) | 7494 | split-width-threshold) |
| 7476 | (setq window (window--try-to-split-window | 7495 | (setq window (window--try-to-split-window |
| 7477 | (selected-window) alist))) | 7496 | (selected-window) alist))) |
| 7478 | (window--display-buffer | 7497 | (window--display-buffer |
| 7479 | buffer window 'window alist display-buffer-mark-dedicated)) | 7498 | buffer window 'window alist display-buffer-mark-dedicated)) |
| 7480 | (and (setq window (window-in-direction 'below)) | 7499 | (and (setq window (window-in-direction 'below)) |
| 7481 | (not (window-dedicated-p window)) | 7500 | (not (window-dedicated-p window)) |
| 7501 | (or (not (numberp min-height)) | ||
| 7502 | ;; A window that showed another buffer before cannot | ||
| 7503 | ;; be resized. | ||
| 7504 | (>= (window-height window) min-height)) | ||
| 7482 | (window--display-buffer | 7505 | (window--display-buffer |
| 7483 | buffer window 'reuse alist display-buffer-mark-dedicated))))) | 7506 | buffer window 'reuse alist display-buffer-mark-dedicated))))) |
| 7484 | 7507 | ||
| 7485 | (defun display-buffer--maybe-at-bottom (buffer alist) | 7508 | (defun display-buffer--maybe-at-bottom (buffer alist) |
| 7486 | (let ((alist (append alist `(,(if temp-buffer-resize-mode | 7509 | (let ((alist (append alist `(,(if temp-buffer-resize-mode |