]> code.delx.au - gnu-emacs-elpa/commitdiff
Special case empty ivy-count-format completion.
authorStephen Whipple <shw@wicdmedia.org>
Fri, 15 Jan 2016 12:24:29 +0000 (05:24 -0700)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 15 Jan 2016 13:08:51 +0000 (14:08 +0100)
- Switch ivy-count-format test to empty string rather than nil.
- Since the prompt is based on user input, sanitize the prompt to
  later be formatted, except in the case of empty ivy-count-format.

Fixes #349

ivy.el

diff --git a/ivy.el b/ivy.el
index 33c9017954f5ab981b697a06be136e09ed853887..96b04e00cd69f4a71a2977debfa357141e6304c4 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1412,10 +1412,14 @@ The previous string is between `ivy-completion-beg' and `ivy-completion-end'."
              (substring-no-properties
               (car comps))))
         (let* ((w (1+ (floor (log (length comps) 10))))
-               (ivy-count-format (and ivy-count-format
-                                      (format "%%-%dd " w))))
+               (ivy-count-format (if (string= ivy-count-format "")
+                                     ivy-count-format
+                                   (format "%%-%dd " w)))
+               (prompt (format "(%s): " str)))
           (and
-           (ivy-read (format "(%s): " str)
+           (ivy-read (if (string= ivy-count-format "")
+                         prompt
+                       (replace-regexp-in-string "%" "%%" prompt))
                      ;; remove 'completions-first-difference face
                      (mapcar #'substring-no-properties comps)
                      :predicate predicate