all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: emacs-devel@gnu.org
Subject: [PATCH] completions-max-height
Date: Mon, 7 Mar 2022 22:07:40 +0100	[thread overview]
Message-ID: <20220307210740.veiocemir46mmerk@Ergus> (raw)
In-Reply-To: 20220307210740.veiocemir46mmerk.ref@Ergus

[-- Attachment #1: Type: text/plain, Size: 66 bytes --]

Hi:

Do you think that this may be added to vanilla?

Best,
Ergus

[-- Attachment #2: completions-max-height.patch --]
[-- Type: text/plain, Size: 1920 bytes --]

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

       reply	other threads:[~2022-03-07 21:07 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 ` Ergus [this message]
2022-03-07 22:10   ` [PATCH] completions-max-height Philip Kaludercic
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=20220307210740.veiocemir46mmerk@Ergus \
    --to=spacibba@aol.com \
    --cc=emacs-devel@gnu.org \
    /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.