Subject: Re: bug#19355: 25.0.50; limit the popup window height

From: martin rudalics <[email-masked]>
Date: Sat, 13 Dec 2014 11:21:24 +0100

> Thanks for the clarification. We are on the same page. I don't have
 > anything specific to add. Just want to point out that
 > fit-window-to-buffer is probably not the cause for this specific bug.
 > The contents of the elisp buffer can be a few windowful and I am still
 > seeing it being squeezed to 4 lines.

There's no specific bug here.  What you report can be easily considered
a user error like choosing a too broad base for completions or failing
to appropriately customize the option `window-min-height'.

But even if we decide that Emacs made a bad choice when making the
*Completions* that large we'd have to decide which heuristics we want to
apply instead, like

- use `shrink-window-if-larger-than-buffer' instead of
   `fit-window-to-buffer',

- explicitly pass a hardocded maximum height/width argument to
   `fit-window-to-buffer' (requires some minor changes to
   `with-displayed-buffer-window')

- add some options that allow users to specify the minimum and maximum
   sizes of _any_ window resized by `fit-window-to-buffer',

- tell users that they should customize `display-buffer' appropriately
   (in this case `with-displayed-buffer-window' would have to do much
   more work than it does now).

In any case, if you want the present behavior to change, you have to
express what you want Emacs to do instead ;-)

As an aside, I observe that displaying the *Completions* window
currently induces three calls to `fit-window-to-buffer' which aren't
that cheap, especially when the buffer is large.

martin