branch: master commit f9974e80f4440cb50e1a005efe9300f5d9476535 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Allow to see the candidate index via ivy-count-format * ivy.el (ivy--insert-prompt): Update. To use this feature, use something like this: (setq ivy-count-format "(%d/%d)") Basically two number specifiers instead of the usual one. The problem with this approach is that the prompt length will change as you scroll e.g. from 9 to 10, which is uncomfortable. Fixes #167 --- ivy.el | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ivy.el b/ivy.el index 9a27ebd..25720c9 100644 --- a/ivy.el +++ b/ivy.el @@ -1155,21 +1155,29 @@ Insert .* between each char." (let ((inhibit-read-only t) (std-props '(front-sticky t rear-nonsticky t field t read-only t)) (n-str - (format (concat (if (and (bound-and-true-p minibuffer-depth-indicate-mode) (> (minibuffer-depth) 1)) (format "[%d] " (minibuffer-depth)) "") - head - ivy--prompt-extra - tail + (if (string-match "%[-0-9 ]*d.*%[-0-9 ]*d" ivy-count-format) + (concat (format ivy-count-format (1+ ivy--index) ivy--length) + " " + ;; work around swiper + (let ((pr (ivy-state-prompt ivy-last))) + (if (string-match "%[-0-9 ]*d" pr) + (substring pr (1+ (match-end 0))) + pr))) + (concat (format + head + (or (and (ivy-state-dynamic-collection ivy-last) + ivy--full-length) + ivy--length)) + ivy--prompt-extra + tail)) (if ivy--directory (abbreviate-file-name ivy--directory) - "")) - (or (and (ivy-state-dynamic-collection ivy-last) - ivy--full-length) - ivy--length)))) + "")))) (save-excursion (goto-char (point-min)) (delete-region (point-min) (minibuffer-prompt-end))