Subject: bug#55169: Can't combine window-min-height with window-height

From: martin rudalics <[email-masked]>
Date: Thu, 5 May 2022 09:47:17 +0200

> I didn't expect that 'split-window-sensibly' should pay attention
 > to 'window-min-height'.  I though only 'display-buffer-*' are affected.

'split-window-sensibly' is the function 'display-buffer-pop-up-window'
runs by default to make a new window.  The dilemma is the following:
'display-buffer-below-selected', before it tries to split the selected
window, asserts that

              (or (not (numberp min-height))
		 (window-sizable-p nil (- min-height)))

where 'min-height' is (cdr (assq 'window-min-height alist)).

'split-window-sensibly', however, may split off a window that is less
than 'min-height' lines high and cannot be enlarged afterwards either.
So far, this is OK because in the manual, in wise foresight, we say for
‘window-min-height’ that "The only client of this entry is presently
‘display-buffer-below-selected’".  But if we obey 'window-min-height' in
'window--display-buffer', then 'display-buffer-pop-up-window' becomes a
client of 'window-min-height' without, however, fulfilling its premise
which says that "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.".

We obviously could call 'split-window-sensibly' with an extra ALIST
argument and have it obey the 'window-min-height' constraint.  But
'split-window-sensibly' is just the default value of the option
'split-window-preferred-function' (all these were invented some time
before 'display-buffer-alist') and that function accepts only one
argument.  So we would have to amend 'window--try-to-split-window' as

		   (or (condition-case nil
		           (funcall split-window-preferred-function window alist)
		         (error nil))
		       (condition-case nil
		           (funcall split-window-preferred-function window)
		         (error nil)))))

No great deal but spilling out the details in the manual will inevitably
increase the mythical confusion around 'display-buffer-alist'.

martin