[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 783f7c5 13/63: Update index formatting logic
From: |
Oleh Krehel |
Subject: |
[elpa] master 783f7c5 13/63: Update index formatting logic |
Date: |
Fri, 21 Aug 2015 12:08:32 +0000 |
branch: master
commit 783f7c58776d1309c84586799f31e0fe6ec64482
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Update index formatting logic
* ivy.el (ivy--reset-state): Update.
(ivy--insert-prompt): Simplify.
If you want to see both the index and the length of the candidates,
instead of just the length, it can be done like this:
(setq ivy-count-format "%d/%d ")
Each "%d" is replaced appropriately due to the total length of the
candidates. For instance, this one can result in "%4d/%-4d M-x ".
Re #167
---
ivy.el | 53 +++++++++++++++++++++++++++++++----------------------
swiper.el | 3 +--
2 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/ivy.el b/ivy.el
index 25720c9..27f76d1 100644
--- a/ivy.el
+++ b/ivy.el
@@ -927,6 +927,17 @@ This is useful for recursive `ivy-read'."
(setq ivy--prompt
(cond ((string-match "%.*d" prompt)
prompt)
+ ((string-match "%d.*%d" ivy-count-format)
+ (let ((w (length (number-to-string
+ (length ivy--all-candidates))))
+ (s (copy-sequence ivy-count-format)))
+ (string-match "%d" s)
+ (match-end 0)
+ (string-match "%d" s (match-end 0))
+ (setq s (replace-match (format "%%-%dd" w) nil nil s))
+ (string-match "%d" s)
+ (concat (replace-match (format "%%%dd" w) nil nil s)
+ prompt)))
((string-match "%.*d" ivy-count-format)
(concat ivy-count-format prompt))
(ivy--directory
@@ -1155,29 +1166,27 @@ Insert .* between each char."
(let ((inhibit-read-only t)
(std-props '(front-sticky t rear-nonsticky t field t read-only t))
(n-str
+ (concat
+ (if (and (bound-and-true-p minibuffer-depth-indicate-mode)
+ (> (minibuffer-depth) 1))
+ (format "[%d] " (minibuffer-depth))
+ "")
(concat
- (if (and (bound-and-true-p minibuffer-depth-indicate-mode)
- (> (minibuffer-depth) 1))
- (format "[%d] " (minibuffer-depth))
- "")
- (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)
- ""))))
+ (if (string-match "%d.*%d" ivy-count-format)
+ (format head
+ (1+ ivy--index)
+ (or (and (ivy-state-dynamic-collection ivy-last)
+ ivy--full-length)
+ ivy--length))
+ (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)
+ ""))))
(save-excursion
(goto-char (point-min))
(delete-region (point-min) (minibuffer-prompt-end))
diff --git a/swiper.el b/swiper.el
index 1975ae2..24be153 100644
--- a/swiper.el
+++ b/swiper.el
@@ -244,8 +244,7 @@ Please remove it and update the \"swiper\" package."))
res)
(unwind-protect
(setq res (ivy-read
- (replace-regexp-in-string
- "%s" "pattern: " swiper--format-spec)
+ "Swiper: "
candidates
:initial-input initial-input
:keymap swiper-map
- [elpa] master 1aa7520 03/63: Add a custom keymap for counsel-find-file, (continued)
- [elpa] master 1aa7520 03/63: Add a custom keymap for counsel-find-file, Oleh Krehel, 2015/08/21
- [elpa] master 9bbf9f9 04/63: Fixup the last two commits, Oleh Krehel, 2015/08/21
- [elpa] master b465c09 06/63: ivy.el (ivy-switch-buffer): Add a multi-action interface, Oleh Krehel, 2015/08/21
- [elpa] master 082fbbc 05/63: Add a multi-action interface for counsel-locate, Oleh Krehel, 2015/08/21
- [elpa] master 548a766 08/63: ivy.el (ivy--reset-state): Fixup, Oleh Krehel, 2015/08/21
- [elpa] master fe6d2b1 07/63: Make ffap work again, Oleh Krehel, 2015/08/21
- [elpa] master f6f3963 09/63: Bind case-fold-search to t when the input is all lower-case, Oleh Krehel, 2015/08/21
- [elpa] master d5af987 11/63: ivy.el (ivy--reset-state): Fixup, Oleh Krehel, 2015/08/21
- [elpa] master d1f88fa 10/63: ivy.el (ivy-read): Don't put empty string on history, Oleh Krehel, 2015/08/21
- [elpa] master f9974e8 12/63: Allow to see the candidate index via ivy-count-format, Oleh Krehel, 2015/08/21
- [elpa] master 783f7c5 13/63: Update index formatting logic,
Oleh Krehel <=
- [elpa] master 3164753 14/63: counsel.el (counsel-locate-history): Add, Oleh Krehel, 2015/08/21
- [elpa] master 19dcc0f 16/63: ivy.el (ivy--regex): Improve for trailing backslash, Oleh Krehel, 2015/08/21
- [elpa] master ea6525e 18/63: ivy.el (ivy-read): Improve ivy-set-actions interaction, Oleh Krehel, 2015/08/21
- [elpa] master e9c2538 19/63: counsel.el (counsel-rhythmbox-history): Add, Oleh Krehel, 2015/08/21
- [elpa] master 21007c2 17/63: Add counsel-rhythmbox, Oleh Krehel, 2015/08/21
- [elpa] master de2e819 20/63: Allow % in prompt string, Oleh Krehel, 2015/08/21
- [elpa] master 22ee8a6 23/63: swiper.el (swiper-font-lock-ensure): Ignore Man-mode, Oleh Krehel, 2015/08/21
- [elpa] master 8c91662 22/63: ivy.el (ivy-call): Bind to "C-M-m" or "M-RET", Oleh Krehel, 2015/08/21
- [elpa] master 3df2d8e 26/63: ivy-hydra.el: Add featurep for hydra, Oleh Krehel, 2015/08/21
- [elpa] master d289b78 15/63: Add a new interface to customize additional exit points, Oleh Krehel, 2015/08/21