* Set max size for *Completions*
[not found] <8735jtn6ug.fsf.ref@aol.com>
@ 2022-03-07 15:02 ` Ergus
2022-03-07 15:17 ` Philip Kaludercic
0 siblings, 1 reply; 3+ messages in thread
From: Ergus @ 2022-03-07 15:02 UTC (permalink / raw)
To: help-gnu-emacs
Hi:
Do we have any way to specify a max size/height for the *Completions*
window??
Best,
Ergus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Set max size for *Completions*
2022-03-07 15:02 ` Set max size for *Completions* Ergus
@ 2022-03-07 15:17 ` Philip Kaludercic
2022-03-07 20:50 ` Ergus
0 siblings, 1 reply; 3+ messages in thread
From: Philip Kaludercic @ 2022-03-07 15:17 UTC (permalink / raw)
To: Ergus; +Cc: help-gnu-emacs
Ergus <spacibba@aol.com> writes:
> Hi:
>
> Do we have any way to specify a max size/height for the *Completions*
> window??
One way it to enable temp-buffer-resize-mode and then set
temp-buffer-max-height to whatever size you want. This might have the
unintended side effect that other windows are also affected. I manged
to solve this by setting temp-buffer-max-height to a function:
(lambda (buf)
(if (string-match-p
(rx bos (or "*Completions*") eos)
(buffer-name buf))
10 (window-height)))
--
Philip Kaludercic
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Set max size for *Completions*
2022-03-07 15:17 ` Philip Kaludercic
@ 2022-03-07 20:50 ` Ergus
0 siblings, 0 replies; 3+ messages in thread
From: Ergus @ 2022-03-07 20:50 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: help-gnu-emacs
On Mon, Mar 07, 2022 at 03:17:45PM +0000, Philip Kaludercic wrote:
>Ergus <spacibba@aol.com> writes:
>
>> Hi:
>>
>> Do we have any way to specify a max size/height for the *Completions*
>> window??
>
>One way it to enable temp-buffer-resize-mode and then set
>temp-buffer-max-height to whatever size you want. This might have the
>unintended side effect that other windows are also affected. I manged
>to solve this by setting temp-buffer-max-height to a function:
>
> (lambda (buf)
> (if (string-match-p
> (rx bos (or "*Completions*") eos)
> (buffer-name buf))
> 10 (window-height)))
>
>--
> Philip Kaludercic
>
Thanks for your reply I actually did this:
(defcustom completions-max-height 10
"Maximum height for *Completions* buffer.")
(defun my/completions-advise (&optional win &rest _)
"Advise for completion resize."
(when-let* (((windowp win))
(bname (buffer-name (window-buffer win))))
(when (string= bname "*Completions*")
(fit-window-to-buffer win completions-max-height))))
(advice-add #'fit-window-to-buffer :after-until #'my/completions-advise)
So I don't need to set temp-buffer-resize-mode or override a
funtion... But of course, this only works with temp-buffer-resize-mode
disabled, maybe adding a custom for this in minibuffer.el changing these
lines:
2278 ,(if temp-buffer-resize-mode
2279 '(window-height . resize-temp-buffer-window)
2280 '(window-height . fit-window-to-buffer))
And use a wrapper only for completions.
(defcustom completions-max-height 10
"Maximum height for *Completions* buffer.")
(defun completions--fit-window-to-buffer (&optional win &rest _)
"Resize completions."
(if temp-buffer-resize-mode
(let ((temp-buffer-max-height (or completions-max-height
temp-buffer-max-height)))
(resize-temp-buffer-window win))
(fit-window-to-buffer win completions-max-height)))
2278 '(window-height . completions--fit-window-to-buffer)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-07 20:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <8735jtn6ug.fsf.ref@aol.com>
2022-03-07 15:02 ` Set max size for *Completions* Ergus
2022-03-07 15:17 ` Philip Kaludercic
2022-03-07 20:50 ` Ergus
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.