[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3256d68 07/90: Change the :matcher interface
From: |
Oleh Krehel |
Subject: |
[elpa] master 3256d68 07/90: Change the :matcher interface |
Date: |
Tue, 30 Jun 2015 07:27:59 +0000 |
branch: master
commit 3256d68f17c9cf6247185419323c7b9ecfc48873
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Change the :matcher interface
* ivy.el (ivy--filter): The matcher is now a function that takes a
regexp and candidates and returns the filtered candidates.
* counsel.el (counsel-git-grep-matcher): Cache matched candidates. This
is very important for "C-n" / "C-p", especially near the threshold
where a switch to :dynamic-collection is made.
---
counsel.el | 38 +++++++++++++++++++++++---------------
ivy.el | 3 +--
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/counsel.el b/counsel.el
index c0581e5..400684c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -251,21 +251,29 @@
:action #'counsel-git-grep-action
:unwind #'swiper--cleanup)))
-(defun counsel-git-grep-matcher (x)
- (ignore-errors
- (when (string-match "^[^:]+:[^:]+:" x)
- (setq x (substring x (match-end 0)))
- (if (stringp ivy--old-re)
- (string-match ivy--old-re x)
- (let ((res t))
- (dolist (re ivy--old-re)
- (setq res
- (and res
- (ignore-errors
- (if (cdr re)
- (string-match (car re) x)
- (not (string-match (car re) x)))))))
- res)))))
+(defun counsel-git-grep-matcher (regexp candidates)
+ (or (and (equal regexp ivy--old-re)
+ ivy--old-cands)
+ (prog1
+ (setq ivy--old-cands
+ (cl-remove-if-not
+ (lambda (x)
+ (ignore-errors
+ (when (string-match "^[^:]+:[^:]+:" x)
+ (setq x (substring x (match-end 0)))
+ (if (stringp regexp)
+ (string-match regexp x)
+ (let ((res t))
+ (dolist (re regexp)
+ (setq res
+ (and res
+ (ignore-errors
+ (if (cdr re)
+ (string-match (car re) x)
+ (not (string-match (car re)
x)))))))
+ res)))))
+ candidates))
+ (setq ivy--old-re regexp))))
(defun counsel-locate-function (str &rest _u)
(if (< (length str) 3)
diff --git a/ivy.el b/ivy.el
index e8299fa..9fc4624 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1080,8 +1080,7 @@ CANDIDATES are assumed to be static."
(matcher (ivy-state-matcher ivy-last))
(cands (cond
(matcher
- (let ((ivy--old-re re))
- (cl-remove-if-not matcher candidates)))
+ (funcall matcher re candidates))
((and (equal re ivy--old-re)
ivy--old-cands)
ivy--old-cands)
- [elpa] master updated (e8eaf1a -> 55e0188), Oleh Krehel, 2015/06/30
- [elpa] master 4a3d0be 01/90: swiper.el (swiper-avy): Use only the current window, Oleh Krehel, 2015/06/30
- [elpa] master 856e1bd 02/90: ivy.el (ivy-next-line): Fix wraparound at end of candidates, Oleh Krehel, 2015/06/30
- [elpa] master 04b5734 03/90: swiper.el (swiper-avy): Don't start on empty input, Oleh Krehel, 2015/06/30
- [elpa] master 23ffd5c 04/90: swiper.el (swiper--ivy): Don't double-quote preselect, Oleh Krehel, 2015/06/30
- [elpa] master d975e1a 06/90: Avoid ensuring font lock when magit-blame-mode is active, Oleh Krehel, 2015/06/30
- [elpa] master 5fdb7de 05/90: Allow to open an Info file on the file system, Oleh Krehel, 2015/06/30
- [elpa] master f899a22 08/90: Add info lookup binding to counsel-describe-map, Oleh Krehel, 2015/06/30
- [elpa] master a0347d8 09/90: counsel.el (counsel-info-lookup-symbol): Add a require, Oleh Krehel, 2015/06/30
- [elpa] master 3256d68 07/90: Change the :matcher interface,
Oleh Krehel <=
- [elpa] master 5f7c787 11/90: counsel.el (counsel-find-file-at-point): New defcustom, Oleh Krehel, 2015/06/30
- [elpa] master efd74b8 10/90: counsel.el (counsel-find-file): Extend `find-file', Oleh Krehel, 2015/06/30
- [elpa] master 8212110 15/90: Handle symbol-at-point better in non-Elisp buffers, Oleh Krehel, 2015/06/30
- [elpa] master fe057eb 14/90: Swiper should preserve column for empty input, Oleh Krehel, 2015/06/30
- [elpa] master 1a193b0 16/90: ivy.el (ivy--done): Set ivy--current, Oleh Krehel, 2015/06/30
- [elpa] master 97abd3c 17/90: ivy.el (ivy-virtual): New defface, Oleh Krehel, 2015/06/30
- [elpa] master 3c8daba 19/90: Fixup compilation warnings, Oleh Krehel, 2015/06/30
- [elpa] master ecb93a6 18/90: Regexp-quote name of candidate buffer to be preselected, Oleh Krehel, 2015/06/30
- [elpa] master 40a938b 21/90: ivy.el (ivy-minibuffer-map): Bind ivy-yank-word to "M-j", Oleh Krehel, 2015/06/30
- [elpa] master 00a1b02 22/90: counsel-git-grep should quote strings better, Oleh Krehel, 2015/06/30