emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master d2b3a37: New buffer display action alist entry 'win


From: Martin Rudalics
Subject: [Emacs-diffs] master d2b3a37: New buffer display action alist entry 'window-min-height' (Bug#32825)
Date: Sat, 8 Dec 2018 03:38:20 -0500 (EST)

branch: master
commit d2b3a37886d97abdc10e16f6389200e8ad45dd7a
Author: Martin Rudalics <address@hidden>
Commit: Martin Rudalics <address@hidden>

    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.
---
 doc/lispref/windows.texi | 22 ++++++++++++++++++++++
 etc/NEWS                 |  6 ++++++
 lisp/window.el           | 41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index b86bcca..eb05766 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -2607,6 +2607,12 @@ suitable @code{window-height} or @code{window-width} 
entry, see above.
 If splitting the selected window fails and there is a non-dedicated
 window below the selected one showing some other buffer, this function
 tries to use that window for showing @var{buffer}.
+
+If @var{alist} contains a @code{window-min-height} entry, this
+function ensures that the window used is or can become at least as
+high as specified by that entry's value.  Note that this is only a
+guarantee.  In order to actually resize the window used, @var{alist}
+must also provide an appropriate @code{window-height} entry.
 @end defun
 
 @defun display-buffer-at-bottom buffer alist
@@ -2790,6 +2796,22 @@ The value specifies an alist of window parameters to 
give the chosen
 window.  All action functions that choose a window should process this
 entry.
 
address@hidden address@hidden, a buffer display action alist entry}
address@hidden window-min-height
+The value specifies a minimum height of the window used, in lines.  If
+a window is not or cannot be made as high as specified by this entry,
+the window is not considered for use.  The only client of this entry
+is presently @code{display-buffer-below-selected}.
+
+Note that providing such an entry alone does not necessarily make the
+window as tall as specified by its value.  To actually resize an
+existing window or make a new window as tall as specified by that
+value, a @code{window-height} entry specifying that value should be
+provided as well.  Such a @code{window-height} entry can, however,
+specify a completely different value or ask the window height to be
+fit to that of its buffer in which case the @code{window-min-height}
+entry provides the guaranteed minimum height of the window used.
+
 @vindex address@hidden, a buffer display action alist entry}
 @item window-height
 The value specifies whether and how to adjust the height of the chosen
diff --git a/etc/NEWS b/etc/NEWS
index cad44f9..7a0db87 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1228,6 +1228,12 @@ A buffer-local value of this hook is now run only if at 
least one
 window showing the buffer has changed its size.
 
 +++
+** New buffer display action alist entry 'window-min-height'.
+Such an entry allows to specify a minimum height of the window used
+for displaying a buffer.  'display-buffer-below-selected' is the only
+action function to respect it at the moment.
+
++++
 ** The function 'assoc-delete-all' now takes an optional predicate argument.
 
 +++
diff --git a/lisp/window.el b/lisp/window.el
index a16ceb4..25a599f 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
 already displays BUFFER, use that window.  Otherwise, try to
 create a new window below the selected one and show BUFFER there.
 If that attempt fails as well and there is a non-dedicated window
-below the selected one, use that window."
-  (let (window)
+below the selected one, use that window.
+
+If ALIST contains a 'window-min-height' entry, this function
+ensures that the window used is or can become at least as high as
+specified by that entry's value.  Note that such an entry alone
+will not resize the window per se.  In order to do that, ALIST
+must also contain a 'window-height' entry with the same value."
+  (let ((min-height (cdr (assq 'window-min-height alist)))
+       window)
     (or (and (setq window (window-in-direction 'below))
-            (eq buffer (window-buffer window))
+             (eq buffer (window-buffer window))
+            (or (not (numberp min-height))
+                (>= (window-height window) min-height)
+                ;; 'window--display-buffer' can resize this window if
+                ;; and only if it has a 'quit-restore' parameter
+                ;; certifying that it always showed BUFFER before.
+                (let ((height (window-height window))
+                      (quit-restore (window-parameter window 'quit-restore)))
+                  (and quit-restore
+                       (eq (nth 1 quit-restore) 'window)
+                       (window-resizable-p window (- min-height height)))))
             (window--display-buffer buffer window 'reuse alist))
        (and (not (frame-parameter nil 'unsplittable))
-            (let ((split-height-threshold 0)
+             (or (not (numberp min-height))
+                (window-sizable-p nil (- min-height)))
+             (let ((split-height-threshold 0)
                   split-width-threshold)
-              (setq window (window--try-to-split-window
+               (setq window (window--try-to-split-window
                              (selected-window) alist)))
-            (window--display-buffer
-             buffer window 'window alist display-buffer-mark-dedicated))
+             (window--display-buffer
+              buffer window 'window alist display-buffer-mark-dedicated))
        (and (setq window (window-in-direction 'below))
-            (not (window-dedicated-p window))
+             (not (window-dedicated-p window))
+            (or (not (numberp min-height))
+                ;; A window that showed another buffer before cannot
+                ;; be resized.
+                (>= (window-height window) min-height))
             (window--display-buffer
-             buffer window 'reuse alist display-buffer-mark-dedicated)))))
+              buffer window 'reuse alist display-buffer-mark-dedicated)))))
 
 (defun display-buffer--maybe-at-bottom (buffer alist)
   (let ((alist (append alist `(,(if temp-buffer-resize-mode



reply via email to

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