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

From: martin rudalics <[email-masked]>
Date: Mon, 2 May 2022 09:37:46 +0200

> Maybe as a workaround two calls of display-buffer would do the trick?
 > The first call display-buffer-below-selected will split the window,
 > then the second call display-buffer-use-some-window will adjust the height.

There would be no benefit in doing such a thing.  The first call might
not be able to produce a window that satisfies the 'window-min-height'
constraint.

A correct solution would be to, before splitting, check whether the
split off window can be made as high as wanted.  For that, we would have
to investigate all possible splittings over all actions allowed by the
ALIST argument to check whether the emanating split would satisfy the
height constraint (where the maximum possible height of a split off
window would be the sum of the total sizes minus their minimum sizes of
all windows in the same combination as the split one).

Our current strategy to usually split just the largest or LRU window is
much too naive in this regard.  The problem with a new approach is that
we would have to tell people that when a 'window-min-height' entry is
present, the display strategy they got used to may change - the new
window might appear in a non-standard position.  Who's to blame?  The
one who bona fides added the 'window-min-height' constraint in a call or
the people who changed the semantics of 'display-buffer'?

BTW I do not understand well in which sense your original scenario

   (pop-to-buffer (generate-new-buffer "*edit string*")
                  '(display-buffer-below-selected
                    (window-min-height . 10)
                    (window-height . fit-window-to-buffer)))

fails.  Do you mean that the window should be at least ten lines high
despite of the fact that it's fit to an empty buffer?

martin