[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 56d7802 15/31: Add an option for multi-tier regex matching
From: |
Oleh Krehel |
Subject: |
[elpa] master 56d7802 15/31: Add an option for multi-tier regex matching |
Date: |
Fri, 01 May 2015 14:28:51 +0000 |
branch: master
commit 56d7802293c03f13a7b052bdf419291d61592ff2
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add an option for multi-tier regex matching
* ivy.el (ivy--regex-plus): New defun. This is an example for the
multi-tier interface.
(ivy--filter): Update.
To use it, add e.g.:
(setq ivy-re-builders-alist
'((t . ivy--regex-plus)))
Example using boost_1_58_0 and `find-file-in-project`:
* "utility" - 234 matches
* "utility hpp" - 139 matches
* "utility !hpp" - 95 matches
Fixes #62
---
ivy.el | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/ivy.el b/ivy.el
index a1c088f..5b440f3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -660,6 +660,23 @@ When GREEDY is non-nil, join words in a greedy way."
".*?")))))
ivy--regex-hash)))))
+(defun ivy--regex-plus (str)
+ "Build a regex sequence from STR.
+Spaces are wild, everything before \"!\" should match.
+Everything after \"!\" should not match."
+ (let ((parts (split-string str "!" t)))
+ (cl-case (length parts)
+ (0
+ "")
+ (1
+ (ivy--regex (car parts)))
+ (2
+ (let ((r2 (ivy--regex (cadr parts)))
+ (r1 (ivy--regex (car parts))))
+ (list (cons r1 t)
+ (cons r2 nil))))
+ (t (error "Unexpected: use only one !")))))
+
;;** Rest
(defun ivy--minibuffer-setup ()
"Setup ivy completion in the minibuffer."
@@ -804,6 +821,8 @@ CANDIDATES are assumed to be static."
ivy--old-cands)
ivy--old-cands)
((and ivy--old-re
+ (stringp re)
+ (stringp ivy--old-re)
(not (string-match "\\\\" ivy--old-re))
(not (equal ivy--old-re ""))
(memq (cl-search
@@ -816,10 +835,17 @@ CANDIDATES are assumed to be static."
(lambda (x) (string-match re x))
ivy--old-cands)))
(t
- (ignore-errors
- (cl-remove-if-not
- (lambda (x) (string-match re x))
- candidates)))))
+ (let ((re-list (if (stringp re) (list (cons re t)) re))
+ (res candidates))
+ (dolist (re re-list)
+ (setq res
+ (funcall
+ (if (cdr re)
+ #'cl-remove-if-not
+ #'cl-remove-if)
+ `(lambda (x) (string-match ,(car re) x))
+ res)))
+ res))))
(tail (nthcdr ivy--index ivy--old-cands))
idx)
(when (and tail ivy--old-cands)
- [elpa] master e356df9 05/31: Reset to the first candidate when switching directories, (continued)
- [elpa] master e356df9 05/31: Reset to the first candidate when switching directories, Oleh Krehel, 2015/05/01
- [elpa] master 94fad10 06/31: Improve the match confirm while completing files, Oleh Krehel, 2015/05/01
- [elpa] master c816430 07/31: Minibuffer faces should inherit minibuffer-prompt, Oleh Krehel, 2015/05/01
- [elpa] master b2c9a20 09/31: Store the preselect and use it for empty ivy-text, Oleh Krehel, 2015/05/01
- [elpa] master 988b78f 08/31: Improve completion history using the propertize trick, Oleh Krehel, 2015/05/01
- [elpa] master eb43e4a 10/31: ivy.el (ivy-alt-done): Treat `ivy-text' with ":" verbatim, Oleh Krehel, 2015/05/01
- [elpa] master 00810d6 11/31: ivy.el (ivy--filter): Fixup, Oleh Krehel, 2015/05/01
- [elpa] master 7f04019 12/31: swiper.el (swiper-font-lock-ensure): Exclude `elfeed-search-mode', Oleh Krehel, 2015/05/01
- [elpa] master 278870e 13/31: Use alpha compositing to add ivy-current-match face, Oleh Krehel, 2015/05/01
- [elpa] master 57de44c 14/31: Makefile: Update, Oleh Krehel, 2015/05/01
- [elpa] master 56d7802 15/31: Add an option for multi-tier regex matching,
Oleh Krehel <=
- [elpa] master 7299950 16/31: ivy.el: Fixup docstrings, Oleh Krehel, 2015/05/01
- [elpa] master aa9d4a7 17/31: ivy.el (ivy-re-builders-alist): Improve doc, Oleh Krehel, 2015/05/01
- [elpa] master 0f141f5 18/31: counsel.el (counsel-git-grep): Add optional initial-input, Oleh Krehel, 2015/05/01
- [elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion, Oleh Krehel, 2015/05/01
- [elpa] master ae2fd1a 21/31: Improve hidden buffer completion further, Oleh Krehel, 2015/05/01
- [elpa] master 5dc26fb 20/31: Improve the completion of hidden buffers, Oleh Krehel, 2015/05/01
- [elpa] master 1332b19 22/31: ivy.el (ivy--exhibit): Fixup last commit, Oleh Krehel, 2015/05/01
- [elpa] master 6b2e95a 24/31: Add gamma-correction to alpha-blending, Oleh Krehel, 2015/05/01
- [elpa] master a868705 23/31: colir.el: Add two additional blend algorithms, Oleh Krehel, 2015/05/01
- [elpa] master 7bd6003 25/31: Update and improve faces, Oleh Krehel, 2015/05/01