Subject: bug#36859: Customizable fit-window-to-buffer

From: Juri Linkov <[email-masked]>
Date: Sun, 04 Aug 2019 00:16:45 +0300

>> I hope it would be possible to specify a special action alist entry
>> in 'display-buffer-alist' , e.g.
>>
>>    (window-height . no-fit-window)
>
> Wouldn't just (window-height) suffice?

Maybe, I'm not sure if the case when window-height is missing in alist
can be distinguished from the case when window-height is nil.

>> Do you think this is feasible?  If not, then maybe these commands
>> should provide post-display hooks such as e.g. 'proced-post-display-hook'
>> where 'fit-window-to-buffer' is added by default, but can be removed
>> by customization.
>
> We could introduce a new ALIST argument, say 'pre-display-function'.
> The function specified there would be called before running the body
> of 'window--display-buffer'.  In the case at hand, that function would
> fill the buffer so OT1H 'shrink-window-if-larger-than-buffer' would
> know the real buffer size and OTOH a 'window-height' entry would allow
> to override that.  I wouldn't know whether and how to suitably pass
> any arguments to such a function, though.

Or maybe 'shrink-window-if-larger-than-buffer' could be added in the body
of another new ALIST argument 'post-display-function'.