bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39822: 27.0.90; Cannot set *Completions* buffer height using display


From: martin rudalics
Subject: bug#39822: 27.0.90; Cannot set *Completions* buffer height using display-buffer-alist
Date: Sat, 29 Feb 2020 08:53:18 +0100

> Testing with 'emacs -Q' and the following snippet:
>
> (add-to-list 'display-buffer-alist
>               '("\\*Completions\\*"
>                 (display-buffer-in-side-window)
>                 (window-height . 0.05)
>                 (side . bottom)
>                 (slot . 0)
>                 (window-parameters . ((no-other-window . t)))))
>
> Seems like the 'window-height' parameter is being ignored and I'm unable
> to set the height for the *Completions* window this way.

You _are_ able to do that since

(display-buffer (get-buffer-create "*Completions*"))

displays the buffer as intended within the bounds of the value you
supplied, the size of the frame, the number of windows it shows ...

> Switching window direction to 'left' or 'right' and setting
> 'window-width' instead of height seems to be working with this altered
> snippet:
>
> (add-to-list 'display-buffer-alist
>               '("\\*Completions\\*"
>                 (display-buffer-in-side-window)
>                 (window-width . 0.05)
>                 (side . right)
>                 (slot . 0)
>                 (window-parameters . ((no-other-window . t)))))
>
> The 'window-height' parameter gets ignored only when specifying the
> 'top' or 'bottom' side.

What happens is that the function responsible for displaying completions
('minibuffer-completion-help') uses the 'with-displayed-buffer-window'
macro and supplies it with a

               '(window-height . fit-window-to-buffer)

argument.  'with-displayed-buffer-window', in these two parts

              (vheight-function
               (let ((window-height (assq 'window-height (cdr ,vaction))))
                 (when (functionp (cdr window-height))
                   (cdr window-height))))

and

         (when vheight-function
           (ignore-errors
             (set-window-parameter ,window 'preserve-size nil)
             (funcall vheight-function ,window)))

uses the above supplied 'fit-window-to-buffer' to override the 0.05
window-height value supplied by your customization.

When you display *Completions* in a side window below or above an
already existing side window, you may observe a similar effect for a
side window on the left or right of your frame.  And if
'fit-window-to-buffer-horizontally' is non-nil, you may see the effect
even when there is only one side window on the left or right even when
window-width is 0.05.

Strictly spoken, the behavior you describe is a bug because
'minibuffer-completion-help' violates the contract obligations of
'display-buffer'.  But displaying completions had its own rules ever
since so I'm not sure what to suggest.

martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]