[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5a4ede4 130/348: Fix swiper-all for ivy--regex-ignore-orde
From: |
Oleh Krehel |
Subject: |
[elpa] master 5a4ede4 130/348: Fix swiper-all for ivy--regex-ignore-order |
Date: |
Sat, 8 Apr 2017 11:03:42 -0400 (EDT) |
branch: master
commit 5a4ede4e4c6c6a82e932d201d7ae04522646dcc6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix swiper-all for ivy--regex-ignore-order
* ivy.el (ivy-re-match): New defun.
* ivy-test.el (ivy-re-match): New test.
* swiper.el (swiper-all-function): Separate the cons regex into two
parts. Check if the second part also matches. Set `ivy--old-re' so
that there's fancy highlighting in the minibuffer.
Fixes #620
---
ivy-test.el | 6 ++++++
ivy.el | 23 +++++++++++++++++++++++
swiper.el | 16 ++++++++++------
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 9cc9313..121e63f 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -401,5 +401,11 @@
"C-u 123 C-m")
123)))
+(ert-deftest ivy-re-match ()
+ (should (ivy-re-match '(("counsel" . t)) "(defun counsel"))
+ (should (ivy-re-match '(("defun" . t) ("counsel" . t)) "(defun counsel"))
+ (should (ivy-re-match '(("counsel" . t) ("defun" . t)) "(defun counsel"))
+ (should (not (ivy-re-match '(("counsel" . nil) ("defun" . t)) "(defun
counsel")))
+ (should (not (ivy-re-match '(("defun" . t) ("counsel" . nil)) "(defun
counsel"))))
(provide 'ivy-test)
diff --git a/ivy.el b/ivy.el
index f9f1d97..1ba266a 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1805,6 +1805,29 @@ Minibuffer bindings:
;;* Implementation
;;** Regex
+(defun ivy-re-match (re-seq str)
+ "Return non-nil if RE-SEQ matches STR.
+
+RE-SEQ is a list of (RE . MATCH-P).
+
+RE is a regular expression.
+
+MATCH-P is t when RE should match STR and nil when RE should not
+match STR.
+
+Each element of RE-SEQ must match for the funtion to return true.
+
+This concept is used to generalize regular expressions for
+`ivy--regex-plus' and `ivy--regex-ignore-order'."
+ (let ((res t)
+ re)
+ (while (and res (setq re (pop re-seq)))
+ (setq res
+ (if (cdr re)
+ (string-match-p (car re) str)
+ (not (string-match-p (car re) str)))))
+ res))
+
(defvar ivy--regex-hash
(make-hash-table :test #'equal)
"Store pre-computed regex.")
diff --git a/swiper.el b/swiper.el
index 7cb95a4..3a96907 100644
--- a/swiper.el
+++ b/swiper.el
@@ -718,10 +718,13 @@ Run `swiper' for those buffers."
(eq (with-current-buffer b
major-mode) 'dired-mode)))
(buffer-list)))
- (re (funcall ivy--regex-function str))
- (re (if (consp re) (caar re) re))
- cands
- match)
+ (re-full (funcall ivy--regex-function str))
+ re re-tail
+ cands match)
+ (if (stringp re-full)
+ (setq re re-full)
+ (setq re (caar re-full))
+ (setq re-tail (cdr re-full)))
(dolist (buffer buffers)
(with-current-buffer buffer
(save-excursion
@@ -739,8 +742,9 @@ Run `swiper' for those buffers."
(buffer-name)
match)
(put-text-property 0 1 'point (point) match)
- (push match cands)))))
- (setq ivy--old-re nil)
+ (when (or (null re-tail) (ivy-re-match re-tail match))
+ (push match cands))))))
+ (setq ivy--old-re re-full)
(if (null cands)
(list "")
(setq ivy--old-cands (nreverse cands))))))
- [elpa] master e4c248a 278/348: doc/ivy.org: Update package names in ELPA/MELPA, (continued)
- [elpa] master e4c248a 278/348: doc/ivy.org: Update package names in ELPA/MELPA, Oleh Krehel, 2017/04/08
- [elpa] master 6e6738c 294/348: counsel.el (counsel-git-grep-cmd-default): Use '%s' quoting, Oleh Krehel, 2017/04/08
- [elpa] master d4e5d79 290/348: counsel.el (counsel-package): Fix sorting issue, Oleh Krehel, 2017/04/08
- [elpa] master 15f89f7 295/348: ivy.el (ivy-minibuffer-map): Bind "C-v" and scroll-up-command, Oleh Krehel, 2017/04/08
- [elpa] master ab6561f 321/348: ivy.el: Use set-ivy-index instead of setq ivy--index, Oleh Krehel, 2017/04/08
- [elpa] master 45383fe 330/348: ivy-overlay.el (ivy-display-function-overlay): Put overlay at symbol start, Oleh Krehel, 2017/04/08
- [elpa] master 1d32ceb 332/348: counsel.el (counsel-irony): New command, Oleh Krehel, 2017/04/08
- [elpa] master ace01d5 347/348: ivy.el (ivy-immediate-done): Fix for rgrep, Oleh Krehel, 2017/04/08
- [elpa] master 2f5bfc0 144/348: counsel.el (counsel-dpkg): New command, Oleh Krehel, 2017/04/08
- [elpa] master d7a1fda 143/348: swiper.el (swiper-all): "M-q" calls query-replace, Oleh Krehel, 2017/04/08
- [elpa] master 5a4ede4 130/348: Fix swiper-all for ivy--regex-ignore-order,
Oleh Krehel <=
- [elpa] master 5787780 137/348: Makefile (plain): Print version, Oleh Krehel, 2017/04/08
- [elpa] master 72784c1 149/348: counsel.el (counsel-imenu): Force rescan if requested, Oleh Krehel, 2017/04/08
- [elpa] master 01b0195 306/348: Correct Circe major-modes in ...-font-lock-exclude, Oleh Krehel, 2017/04/08
- [elpa] master 94a466f 341/348: ivy.el: Clean up whitespace, Oleh Krehel, 2017/04/08
- [elpa] master 1220781 131/348: counsel.el (counsel-find-file): Speed up opening remotes, Oleh Krehel, 2017/04/08
- [elpa] master 63dd0d3 134/348: counsel.el (counsel-git-grep-proj-function): Use greedy regex, Oleh Krehel, 2017/04/08
- [elpa] master d41212e 172/348: ivy.el (ivy--insert-minibuffer): Handle empty string, Oleh Krehel, 2017/04/08
- [elpa] master 8632f33 175/348: counsel.el: Update description comment., Oleh Krehel, 2017/04/08
- [elpa] master 89a6830 186/348: counsel.el (counsel-at-git-issue-p): Fix for newer magit, Oleh Krehel, 2017/04/08
- [elpa] master 3d0e4a5 184/348: counsel.el (counsel-locate-action-extern): Update on w32, Oleh Krehel, 2017/04/08