emacs-diffs
[Top][All Lists]
Advanced

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

feature/completions-customs 09b548fd5e 2/3: completions-max-height new c


From: Jimmy Aguilar Mena
Subject: feature/completions-customs 09b548fd5e 2/3: completions-max-height new custom variable.
Date: Thu, 10 Mar 2022 08:42:43 -0500 (EST)

branch: feature/completions-customs
commit 09b548fd5e7860f363a3d5bf6f975f577b9cd43e
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    completions-max-height new custom variable.
---
 doc/emacs/mini.texi |  7 +++++++
 etc/NEWS            |  5 ++++-
 lisp/minibuffer.el  | 17 ++++++++++++++---
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 5d351dd10b..eb2bfce136 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -658,6 +658,13 @@ changed by changing the @code{completions-format} user 
option.  If
 @code{vertical}, sort the completions vertically in columns instead,
 and if @code{one-column}, just use a single column.
 
+@vindex completions-max-height
+  When @code{completions-max-height} is non-@code{nil} it limits the
+size of the completions window. It is specified in lines and include
+mode, header line and a bottom divider, if any.  For a more complex
+control of the Completion window display properties you can use
+@code{display-buffer-alist} (@pxref{Buffer Display Action Alists}).
+
 @node Minibuffer History
 @section Minibuffer History
 @cindex minibuffer history
diff --git a/etc/NEWS b/etc/NEWS
index 3d32513386..5a0d6c8fdb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -555,7 +555,6 @@ the "*Completions*" buffer.  Available styles are no 
sorting,
 alphabetical (the default), or a custom sort function.
 
 *** New values for the 'completion-auto-select' option.
-
 There are two new values to control the way *Completions* behave after
 a <tab> if completion is not unique.  'always updates or shows
 the *Completions* buffer after any attempt to complete.  'visual is
@@ -563,6 +562,10 @@ like 'always, but only update the completions if they are 
already
 visible.  The default value t always hide the completion buffer after
 some completion is made.
 
+*** 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 c6a803cbc4..cd0c274765 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2205,6 +2205,19 @@ variables.")
                (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)
@@ -2268,9 +2281,7 @@ variables.")
              ,(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 via email to

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