From: Ergus <spacibba@aol.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Set max size for *Completions*
Date: Mon, 7 Mar 2022 21:50:51 +0100 [thread overview]
Message-ID: <20220307205051.f4r6lkhybwtpkbnc@Ergus> (raw)
In-Reply-To: <87sfrtaj1i.fsf@posteo.net>
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)
prev parent reply other threads:[~2022-03-07 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307205051.f4r6lkhybwtpkbnc@Ergus \
--to=spacibba@aol.com \
--cc=help-gnu-emacs@gnu.org \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).