[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d73376f 010/184: ivy.el (ivy--trim-trailing-re): Add
From: |
Oleh Krehel |
Subject: |
[elpa] master d73376f 010/184: ivy.el (ivy--trim-trailing-re): Add |
Date: |
Wed, 16 Oct 2019 13:14:39 -0400 (EDT) |
branch: master
commit d73376f434f801e6f9b1ca05b53eb20368edc512
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy--trim-trailing-re): Add
* swiper.el (swiper--isearch-function): Make use of `ivy--trim-trailing-re'.
Re #2155
---
ivy-test.el | 12 +++++++++---
ivy.el | 10 ++++++++++
swiper.el | 3 ---
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 0d53b07..f8c9727 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -219,7 +219,9 @@ will bring the behavior in line with the newer Emacsen."
"foo\\["))
(should (equal (ivy--regex
".org")
- "\\.org")))
+ "\\.org"))
+ (should (equal (ivy--regex "foo\\") "foo"))
+ (should (equal (ivy--regex "foo\\|") "foo")))
(ert-deftest ivy--split-negation ()
(should (equal (ivy--split-negation "") ()))
@@ -288,7 +290,9 @@ will bring the behavior in line with the newer Emacsen."
(should (string= (ivy--regex-fuzzy "^")
"^"))
(should (string= (ivy--regex-fuzzy "$")
- "$")))
+ "$"))
+ (should (equal (ivy--regex-fuzzy "abc\\|")
+ "\\(a\\)[^b\n]*\\(b\\)[^c\n]*\\(c\\)")))
(ert-deftest ivy--regex-ignore-order ()
(should (equal (ivy--regex-ignore-order "tmux")
@@ -320,7 +324,9 @@ will bring the behavior in line with the newer Emacsen."
(ivy--regex-ignore-order "! ! !")
;; Escape invalid regexps.
(should (equal (ivy--regex-ignore-order "foo[ bar[xy]")
- '(("foo\\[" . t) ("bar[xy]" . t)))))
+ '(("foo\\[" . t) ("bar[xy]" . t))))
+ (should (equal (ivy--regex-ignore-order "foo\\|")
+ '(("foo" . t)))))
(ert-deftest ivy--format ()
(should (string= (let ((ivy--index 10)
diff --git a/ivy.el b/ivy.el
index 58af21a..d580167 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2563,6 +2563,13 @@ regexp is passed to `regexp-quote'."
(push s res)))
(mapcar #'ivy--regex-or-literal (nreverse res))))
+(defun ivy--trim-trailing-re (regex)
+ "Trim incomplete REGEX.
+If REGEX ends with \\|, trim it, since then it matches an empty string."
+ (if (string-match "\\`\\(.*\\)[\\]|\\'" regex)
+ (match-string 1 regex)
+ regex))
+
(defun ivy--regex (str &optional greedy)
"Re-build regex pattern from STR in case it has a space.
When GREEDY is non-nil, join words in a greedy way."
@@ -2574,6 +2581,7 @@ When GREEDY is non-nil, join words in a greedy way."
(cdr hashed))
(when (string-match-p "\\(?:[^\\]\\|^\\)\\\\\\'" str)
(setq str (substring str 0 -1)))
+ (setq str (ivy--trim-trailing-re str))
(cdr (puthash str
(let ((subs (ivy--split str)))
(if (= (length subs) 1)
@@ -2663,6 +2671,7 @@ foo\!bar -> matches \"foo!bar\"
foo\ bar -> matches \"foo bar\"
Returns a list suitable for `ivy-re-match'."
+ (setq str (ivy--trim-trailing-re str))
(let* (regex-parts
(raw-parts (ivy--split-negation str)))
(dolist (part (ivy--split-spaces (car raw-parts)))
@@ -2695,6 +2704,7 @@ match. Everything after \"!\" should not match."
(defun ivy--regex-fuzzy (str)
"Build a regex sequence from STR.
Insert .* between each char."
+ (setq str (ivy--trim-trailing-re str))
(if (string-match "\\`\\(\\^?\\)\\(.*?\\)\\(\\$?\\)\\'" str)
(prog1
(concat (match-string 1 str)
diff --git a/swiper.el b/swiper.el
index 9b57894..f5a09dc 100644
--- a/swiper.el
+++ b/swiper.el
@@ -1340,9 +1340,6 @@ See `ivy-format-functions-alist' for further information."
(unless (equal re-full "")
(let* ((case-fold-search (ivy--case-fold-p str))
(re (ivy-re-to-str re-full))
- (re (if (string-match "\\`\\(.*\\)[\\]|\\'" re)
- (match-string 1 re)
- re))
(res (swiper--isearch-function-1 re swiper--isearch-backward))
(idx-found (car res))
(cands (cdr res)))
- [elpa] master 327dbd6 058/184: counsel.el (counsel-rg-base-command): Don't include directory on non-Windows, (continued)
- [elpa] master 327dbd6 058/184: counsel.el (counsel-rg-base-command): Don't include directory on non-Windows, Oleh Krehel, 2019/10/16
- [elpa] master 5140127 046/184: ivy.el: Run ispell-comments-and-strings, Oleh Krehel, 2019/10/16
- [elpa] master 2ecbd7d 054/184: ivy.el (ivy-read-action-ivy): Show the selected item in the prompt, Oleh Krehel, 2019/10/16
- [elpa] master ae70443 060/184: counsel.el (counsel-major): Add, Oleh Krehel, 2019/10/16
- [elpa] master f66eec5 059/184: Add counsel-buffer-or-recentf, Oleh Krehel, 2019/10/16
- [elpa] master 1303e10 061/184: counsel.el (counsel-M-x-action): Extract, Oleh Krehel, 2019/10/16
- [elpa] master ca5040d 078/184: counsel.el (counsel-rg-base-command): Remove "-S" flag, Oleh Krehel, 2019/10/16
- [elpa] master 20d604c 069/184: ivy.el (ivy-restrict-to-matches): Fix for ivy-resume, Oleh Krehel, 2019/10/16
- [elpa] master c307ae9 055/184: swiper.el (swiper--re-builder): Fix symbol bounds with char-fold-to-regexp, Oleh Krehel, 2019/10/16
- [elpa] master 5424a564 082/184: ivy.el (ivy--handle-directory): Extract, Oleh Krehel, 2019/10/16
- [elpa] master d73376f 010/184: ivy.el (ivy--trim-trailing-re): Add,
Oleh Krehel <=
- [elpa] master 824f8d7 072/184: counsel.el (counsel--find-return-list): Works with or without "./" prefix, Oleh Krehel, 2019/10/16
- [elpa] master 4fef498 065/184: Use file-name-at-point-functions for file commands, Oleh Krehel, 2019/10/16
- [elpa] master 3d0fcb5 064/184: ivy.el (ivy-partial): Fix trailing space issue, Oleh Krehel, 2019/10/16
- [elpa] master 7dea040 066/184: ivy.el (ivy-pre-prompt-function): Add, Oleh Krehel, 2019/10/16
- [elpa] master cd7e924 077/184: ivy.el (ivy-read): Fix docstring, Oleh Krehel, 2019/10/16
- [elpa] master da7e546 085/184: ivy.el (ivy-previous-line-and-call): Fix typo, Oleh Krehel, 2019/10/16
- [elpa] master 03fdaea 087/184: doc/ivy.org: Add more recommended key bindings, Oleh Krehel, 2019/10/16
- [elpa] master 941d408 086/184: doc/ivy.org: Fix "C-M-n" description, Oleh Krehel, 2019/10/16
- [elpa] master 4e9aaec 092/184: ivy-test: Fix tests using file names on Windows, Oleh Krehel, 2019/10/16
- [elpa] master 139816a 106/184: counsel.el (counsel-mark-ring): Add the latest mark to selection, Oleh Krehel, 2019/10/16