Subject: Re: bug#70213: Info-mode side window fit-window-to-buffer issue

From: Stephen Berman <[email-masked]>
Date: Mon, 08 Apr 2024 09:56:25 +0200

On Sun, 07 Apr 2024 16:11:07 -0700 Joseph Turner <[email-masked]> wrote:

> Stephen Berman <[email-masked]> writes:
>
>> On Sun, 07 Apr 2024 10:53:00 -0700 Joseph Turner
>> <[email-masked]> wrote:
>>
>>> martin rudalics <[email-masked]> writes:
>>>
>>>>>> In emacs -Q on master after Jan 6 patch, eval this:
>>>>>
>>>>> Maybe Martin could help to solve this problem (Cc-ed).
>>>>>
>>>>>> (progn
>>>>>>    (setq fit-window-to-buffer-horizontally t)
>>>>>>
>>>>>>    (setq display-buffer-alist
>>>>>>          '(((derived-mode . Info-mode)
>>>>>>             display-buffer-in-side-window
>>>>>>             (side . right)
>>>>>>             (window-width . fit-window-to-buffer))
>>>>>> 	  ((derived-mode . messages-buffer-mode)
>>>>>>             display-buffer-in-side-window
>>>>>>             (side . right)
>>>>>>             (window-width . fit-window-to-buffer)))))
>>>>
>>>> At the time we call 'fit-window-to-buffer' the buffer is empty so we
>>>> show only 'window-min-width' columns.  Don't we have 'body-function' for
>>>> that?
>>>
>>> Thanks for the review!  We have the same understanding of the issue.
>>>
>>> What do you mean by 'body-function'?
>>>
>>>>>> I would expect the *info* window to fit to the buffer contents
>>>>>> when it first appears.  The patch I sent earlier fixes this.
>>>>
>>>> That patch is
>>>>
>>>> Display-buffer-after-ensuring-it-contains-text.patch
>>>
>>>> IIUC.  It already explains the problem in its name and does look good to
>>>> me.
>>>
>>> Thanks for the review!  Stephen, Juri, Eli, WDYT?
>>
>> I agree that your patch is an improvement when
>> fit-window-to-buffer-horizontally is set to t.  However, as I noted
>> upthread, the resulting width of the right-side window is too small,
>> unlike when using the same setting of display-buffer-alist with
>> fit-window-to-buffer-horizontally set to nil, with which the setting of
>> display-buffer-alist works just as well without your patch.  So even
>> with your patch, there remains a problem.
>
> It turns out that it's necessary to set window-resize-pixelwise also, as
> noted in (info "(elisp)Frame Layouts with Side Windows") .
>
> In emacs -Q with the patch, the following snippet should the width of
> the largest line, which on my machine is 74, the width of this line:

Yep, now I get that too (after widening the frame sufficiently, since
the standard default of 80 columns (which I have) is too narrow to fit
both windows with widths 6 and 74 plus the added scroll bar and
fringes).  So window-resize-pixelwise was the missing link, there's no
problem after all and your patch is good to go, as far as I'm concerned.
Thanks.

Steve Berman

>   In Emacs, you can click mouse button 2 on a menu item or cross reference
>
> (progn
>   (setq fit-window-to-buffer-horizontally t)
>   (setq window-resize-pixelwise t)
>
>   (setq display-buffer-alist
>         '(((derived-mode . Info-mode)
>            display-buffer-in-side-window
>            (side . right)
>            (window-width . fit-window-to-buffer))))
>
>   (info)
>   (window-width))