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

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

[elpa] master 0c85d9a 58/67: Add a custom `ivy-count-format'


From: Oleh Krehel
Subject: [elpa] master 0c85d9a 58/67: Add a custom `ivy-count-format'
Date: Sun, 22 Mar 2015 17:34:10 +0000

branch: master
commit 0c85d9ac62a67e8cc175a19779cf28876fc58930
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add a custom `ivy-count-format'
    
    * ivy.el (ivy-count-format): New defcustom.
    (ivy-read): Use `ivy-count-format', unless PROMPT already has a %d spec.
    
    Set `ivy-count-format' to nil or "" if you don't want to see an
    auto-updating match count in the minibuffer.
    
    Re #23.
---
 ivy.el |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ivy.el b/ivy.el
index 34f7ad8..21e6f12 100644
--- a/ivy.el
+++ b/ivy.el
@@ -50,6 +50,11 @@
   "Number of lines for the minibuffer window."
   :type 'integer)
 
+(defcustom ivy-count-format "%-4d "
+  "The style of showing the current candidate count for `ivy-read'.
+Set this to nil if you don't want the count."
+  :type 'string)
+
 ;;* User Visible
 ;;** Keymap
 (require 'delsel)
@@ -166,9 +171,12 @@ the ones that match INITIAL-INPUT."
      (setq ivy-exit nil)
      (setq ivy--default (or (thing-at-point 'symbol) ""))
      (setq ivy--prompt
-           (if (string-match "%.*d" prompt)
-               prompt
-             nil))
+           (cond ((string-match "%.*d" prompt)
+                  prompt)
+                 ((string-match "%.*d" ivy-count-format)
+                  (concat ivy-count-format prompt))
+                 (t
+                  nil)))
      (unwind-protect
           (minibuffer-with-setup-hook
               #'ivy--minibuffer-setup



reply via email to

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