emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ivy-hydra eae1ccf 086/395: ivy.el (ivy-auto-shrink-mini


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra eae1ccf 086/395: ivy.el (ivy-auto-shrink-minibuffer): New defcustom
Date: Thu, 25 Feb 2021 08:31:37 -0500 (EST)

branch: externals/ivy-hydra
commit eae1ccf6f0292830c90059b7b24f396432de02d6
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    ivy.el (ivy-auto-shrink-minibuffer): New defcustom
    
    Fixes #649
    Fixes #2389
---
 ivy.el | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/ivy.el b/ivy.el
index 1748de3..c90276b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3332,6 +3332,10 @@ Should be run via minibuffer `post-command-hook'."
         (when (region-active-p)
           (set-mark old-mark))))))
 
+(defcustom ivy-auto-shrink-minibuffer nil
+  "When non-nil and the height < `ivy-height', auto-shrink the minibuffer."
+  :type 'boolean)
+
 (defun ivy--resize-minibuffer-to-fit ()
   "Resize the minibuffer window size to fit the text in the minibuffer."
   (unless (frame-root-window-p (minibuffer-window))
@@ -3339,13 +3343,19 @@ Should be run via minibuffer `post-command-hook'."
       (if (fboundp 'window-text-pixel-size)
           (let ((text-height (cdr (window-text-pixel-size)))
                 (body-height (window-body-height nil t)))
-            (when (> text-height body-height)
-              ;; Note: the size increment needs to be at least
-              ;; frame-char-height, otherwise resizing won't do
-              ;; anything.
-              (let ((delta (max (- text-height body-height)
-                                (frame-char-height))))
-                (window-resize nil delta nil t t))))
+            (cond ((> text-height body-height)
+                   ;; Note: the size increment needs to be at least
+                   ;; frame-char-height, otherwise resizing won't do
+                   ;; anything.
+                   (let ((delta (max (- text-height body-height)
+                                     (frame-char-height))))
+                     (window-resize nil delta nil t t)))
+                  ((and ivy-auto-shrink-minibuffer
+                        (< ivy--length ivy-height))
+                   (shrink-window (-
+                                   (/ (window-body-height nil t)
+                                      (frame-char-height))
+                                   ivy--length 1)))))
         (let ((text-height (count-screen-lines))
               (body-height (window-body-height)))
           (when (> text-height body-height)



reply via email to

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