branch: master
commit c5dda5004f182cb4acd72e3b2aad8f8d5c19a724
Author: Feng Shu <[email protected]>
Commit: Oleh Krehel <[email protected]>
Add counsel-async-ignore-re
---
counsel.el | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/counsel.el b/counsel.el
index 6f8799f..b9b9c8d 100644
--- a/counsel.el
+++ b/counsel.el
@@ -121,6 +121,9 @@ The time is measured in seconds.")
(defvar counsel-async-split-string-re "\n"
"Store the regexp for splitting shell command output.")
+(defvar counsel-async-ignore-re nil
+ "Candidates matched the regexp will be ignored by `counsel--async-command'.")
+
(defun counsel--async-command (cmd &optional process-sentinel process-filter)
"Start new counsel process by calling CMD.
If a counsel process is already running, kill it and its associated buffer
@@ -207,10 +210,16 @@ Update the minibuffer with the amount of lines collected
every
(goto-char (point-min))
(setq size (- (buffer-size) (forward-line (buffer-size))))
(ivy--set-candidates
- (split-string
- (buffer-string)
- counsel-async-split-string-re
- t)))
+ (let ((strings (split-string (buffer-string)
+ counsel-async-split-string-re
+ t)))
+ (if (and counsel-async-ignore-re
+ (stringp counsel-async-ignore-re))
+ (cl-remove-if
+ (lambda (str)
+ (string-match-p counsel-async-ignore-re str))
+ strings)
+ strings))))
(let ((ivy--prompt (format
(concat "%d++ " (ivy-state-prompt ivy-last))
size)))