branch: master
commit 0c85d9ac62a67e8cc175a19779cf28876fc58930
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
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