[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 56aa605 076/348: ivy.el (ivy-add-prompt-count): Refactor f
From: |
Oleh Krehel |
Subject: |
[elpa] master 56aa605 076/348: ivy.el (ivy-add-prompt-count): Refactor from ivy--reset-state |
Date: |
Sat, 8 Apr 2017 11:03:30 -0400 (EDT) |
branch: master
commit 56aa6056a93e91bab754b802f5fa93bc94ec78ac
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-add-prompt-count): Refactor from ivy--reset-state
* counsel.el (counsel-prompt-function-default): Update.
(counsel-prompt-function-dir): Update.
---
counsel.el | 22 ++++++++++++----------
ivy.el | 48 +++++++++++++++++++++++++-----------------------
2 files changed, 37 insertions(+), 33 deletions(-)
diff --git a/counsel.el b/counsel.el
index 211f8b9..5c1673c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -210,7 +210,8 @@ Update the minibuffer with the amount of lines collected
every
(defun counsel-prompt-function-default ()
"Return prompt appended with a semicolon."
- (format "%s: " (ivy-state-prompt ivy-last)))
+ (ivy-add-prompt-count
+ (format "%s: " (ivy-state-prompt ivy-last))))
(defun counsel-delete-process ()
(let ((process (get-process " *counsel*")))
@@ -889,15 +890,16 @@ Describe the selected candidate."
(defun counsel-prompt-function-dir ()
"Return prompt appended with the parent directory."
- (let ((directory counsel--git-grep-dir))
- (format "%s [%s]: "
- (ivy-state-prompt ivy-last)
- (let ((dir-list (eshell-split-path directory)))
- (if (> (length dir-list) 3)
- (apply #'concat
- (append '("...")
- (cl-subseq dir-list (- (length dir-list) 3))))
- directory)))))
+ (ivy-add-prompt-count
+ (let ((directory counsel--git-grep-dir))
+ (format "%s [%s]: "
+ (ivy-state-prompt ivy-last)
+ (let ((dir-list (eshell-split-path directory)))
+ (if (> (length dir-list) 3)
+ (apply #'concat
+ (append '("...")
+ (cl-subseq dir-list (- (length dir-list)
3))))
+ directory))))))
(defun counsel-git-grep-function (string &optional _pred &rest _unused)
"Grep in the current git repository for STRING."
diff --git a/ivy.el b/ivy.el
index 49b4db5..df1e0cf 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1588,31 +1588,33 @@ This is useful for recursive `ivy-read'."
(region-beginning)
(region-end))
(ivy-thing-at-point)))
- (setq ivy--prompt
- (cond ((string-match "%.*d" prompt)
- prompt)
- ((null ivy-count-format)
- (error
- "`ivy-count-format' can't be nil. Set it to an empty string
instead"))
- ((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
- prompt)
- (t
- prompt)))
+ (setq ivy--prompt (ivy-add-prompt-count prompt))
(setf (ivy-state-initial-input ivy-last) initial-input)))
+(defun ivy-add-prompt-count (prompt)
+ (cond ((string-match "%.*d" prompt)
+ prompt)
+ ((null ivy-count-format)
+ (error
+ "`ivy-count-format' can't be nil. Set it to an empty string
instead"))
+ ((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
+ prompt)
+ (t
+ prompt)))
+
;;;###autoload
(defun ivy-completing-read (prompt collection
&optional predicate require-match initial-input
- [elpa] master 3e1a940 045/348: counsel.el: Fix byte compile warnings, (continued)
- [elpa] master 3e1a940 045/348: counsel.el: Fix byte compile warnings, Oleh Krehel, 2017/04/08
- [elpa] master c960de5 047/348: counsel.el (counsel-grep-or-swiper): Don't grep on compressed files, Oleh Krehel, 2017/04/08
- [elpa] master 2776358 059/348: Show current value of the variable in the prompt, Oleh Krehel, 2017/04/08
- [elpa] master beee0b7 048/348: counsel.el (counsel-git): Add better error message, Oleh Krehel, 2017/04/08
- [elpa] master 65948fc 053/348: colir.el (colir-parse-color): Fix color parsing in terminal, Oleh Krehel, 2017/04/08
- [elpa] master e987cef 061/348: counsel.el (counsel-read-setq-expression): Fix Eldoc nag, Oleh Krehel, 2017/04/08
- [elpa] master 0091c8a 058/348: ivy.el (ivy-set-prompt-text-properties-function): New devar, Oleh Krehel, 2017/04/08
- [elpa] master 473c595 064/348: Facilitate the sorting of cons cell input to ivy-read, Oleh Krehel, 2017/04/08
- [elpa] master 23bd7a4 075/348: counsel.el (counsel-git): Add :caller, Oleh Krehel, 2017/04/08
- [elpa] master 74358c2 070/348: Purge all dependency on helm-rhythmbox, Oleh Krehel, 2017/04/08
- [elpa] master 56aa605 076/348: ivy.el (ivy-add-prompt-count): Refactor from ivy--reset-state,
Oleh Krehel <=
- [elpa] master 9c01abf 003/348: doc/Changelog.org: Add hlines, Oleh Krehel, 2017/04/08
- [elpa] master e53f256 087/348: ivy.el (ivy-minibuffer-map): Move ivy-toggle-regexp-quote from "M-q" to "M-r", Oleh Krehel, 2017/04/08
- [elpa] master af5f097 108/348: counsel.el (counsel-locate-action-extern): Make interactive, Oleh Krehel, 2017/04/08
- [elpa] master 0028c8c 106/348: counsel.el (counsel-outline): New command, Oleh Krehel, 2017/04/08
- [elpa] master 1d8b4f8 110/348: ivy.el (ivy-sort-matches-functions-alist): New sorting for ivy-switch-buffer, Oleh Krehel, 2017/04/08
- [elpa] master 027fbac 114/348: swiper.el (swiper-multi-action-2): Fix swiper-all, Oleh Krehel, 2017/04/08
- [elpa] master d6cf677 077/348: ivy.el (ivy-prompt): Add warning, Oleh Krehel, 2017/04/08
- [elpa] master 9bd79da 074/348: ivy.el (ivy-set-prompt): New API, Oleh Krehel, 2017/04/08
- [elpa] master 72dcca5 082/348: ivy.el (ivy-push-view): Work properly for dired-mode, Oleh Krehel, 2017/04/08
- [elpa] master 3d7e1ef 083/348: ivy.el (ivy--switch-buffer-action): Improve, Oleh Krehel, 2017/04/08