all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Ergus <spacibba@aol.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] completions-max-height
Date: Mon, 07 Mar 2022 22:10:52 +0000	[thread overview]
Message-ID: <87v8wpxvkj.fsf@posteo.net> (raw)
In-Reply-To: <20220307210740.veiocemir46mmerk@Ergus> (Ergus's message of "Mon,  7 Mar 2022 22:07:40 +0100")

Ergus <spacibba@aol.com> writes:

> Hi:
>
> Do you think that this may be added to vanilla?

IMO it would be better if this could be generalised to something like
completion-display-buffer-action, so that you can decide where and how
the completion buffer is displayed.  Though I am uncertain if this might
have unintended side effects, as the behaviour seems to have been
hard-coded for a while.

> Best,
> Ergus
>
> diff --git a/etc/NEWS b/etc/NEWS
> index 587e7f6ade..78f41de2ea 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -554,6 +554,10 @@ This option controls the sorting of the completion candidates in
>  the "*Completions*" buffer.  Available styles are no sorting,
>  alphabetical (the default), or a custom sort function.
>  
> +*** New user option 'completions-max-height'.
> +This option limits the height of the "*Completions*" buffer.
> +
> +
>  ** Isearch and Replace
>  
>  +++
> diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
> index 798cba0ac2..a06986fdb7 100644
> --- a/lisp/minibuffer.el
> +++ b/lisp/minibuffer.el
> @@ -2212,6 +2212,19 @@ completion--done
>                 (equal pre-msg (and exit-fun (current-message))))
>        (completion--message message))))
>  
> +(defcustom completions-max-height nil
> +  "Maximum height for *Completions* buffer."
> +  :type 'natnum
> +  :version "29.1")
> +
> +(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)))
> +
>  (defun minibuffer-completion-help (&optional start end)
>    "Display a list of possible completions of the current minibuffer contents."
>    (interactive)
> @@ -2275,9 +2288,7 @@ minibuffer-completion-help
>               ,(if (eq (selected-window) (minibuffer-window))
>                    'display-buffer-at-bottom
>                  'display-buffer-below-selected))
> -            ,(if temp-buffer-resize-mode
> -                 '(window-height . resize-temp-buffer-window)
> -               '(window-height . fit-window-to-buffer))
> +            (window-height . completions--fit-window-to-buffer)
>              ,(when temp-buffer-resize-mode
>                 '(preserve-size . (nil . t)))
>              (body-function
>

-- 
	Philip Kaludercic



  reply	other threads:[~2022-03-07 22:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220307210740.veiocemir46mmerk.ref@Ergus>
2022-03-07 21:07 ` [PATCH] completions-max-height Ergus
2022-03-07 22:10   ` Philip Kaludercic [this message]
2022-03-08  5:13     ` Protesilaos Stavrou
2022-03-08  8:05       ` Ergus
2022-03-08  8:47         ` Philip Kaludercic
2022-03-08 10:32           ` Ergus
2022-03-08 13:29           ` Ergus
2022-03-09 11:34             ` Ergus

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8wpxvkj.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=emacs-devel@gnu.org \
    --cc=spacibba@aol.com \
    /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.
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.