[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d8172a0 40/90: ivy.el (ivy--regex-fuzzy): Improve for "^"
From: |
Oleh Krehel |
Subject: |
[elpa] master d8172a0 40/90: ivy.el (ivy--regex-fuzzy): Improve for "^" and "$" |
Date: |
Tue, 30 Jun 2015 07:28:23 +0000 |
branch: master
commit d8172a00fdf35aae5023ceb449523a31a7809749
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy--regex-fuzzy): Improve for "^" and "$"
* ivy.el (ivy--regex-fuzzy): Don't insert .* after ^ and before $.
* ivy-test.el (ivy--regex-fuzzy): Add test.
Fixes #139
---
ivy-test.el | 14 ++++++++++++++
ivy.el | 6 +++++-
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 91e0dc3..1062cd8 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -81,3 +81,17 @@
'("We're all Britons"
"and I am"
"your king."))))
+
+(ert-deftest ivy--regex-fuzzy ()
+ (should (string= (ivy--regex-fuzzy "tmux")
+ "t.*m.*u.*x"))
+ (should (string= (ivy--regex-fuzzy "^tmux")
+ "^t.*m.*u.*x"))
+ (should (string= (ivy--regex-fuzzy "^tmux$")
+ "^t.*m.*u.*x$"))
+ (should (string= (ivy--regex-fuzzy "")
+ ""))
+ (should (string= (ivy--regex-fuzzy "^")
+ "^"))
+ (should (string= (ivy--regex-fuzzy "$")
+ "$")))
diff --git a/ivy.el b/ivy.el
index e002e64..07ad9bf 100644
--- a/ivy.el
+++ b/ivy.el
@@ -966,7 +966,11 @@ Everything after \"!\" should not match."
(defun ivy--regex-fuzzy (str)
"Build a regex sequence from STR.
Insert .* between each char."
- (mapconcat #'string (string-to-list str) ".*"))
+ (if (string-match "\\`\\(\\^?\\)\\(.*?\\)\\(\\$?\\)\\'" str)
+ (concat (match-string 1 str)
+ (mapconcat #'string (string-to-list (match-string 2 str)) ".*")
+ (match-string 3 str))
+ str))
;;** Rest
(defun ivy--minibuffer-setup ()
- [elpa] master d24397b 32/90: counsel.el (counsel-M-x-initial-input): New defcustom, (continued)
- [elpa] master d24397b 32/90: counsel.el (counsel-M-x-initial-input): New defcustom, Oleh Krehel, 2015/06/30
- [elpa] master e016d48 31/90: Allow "TAB" to complete when input starts with "^", Oleh Krehel, 2015/06/30
- [elpa] master 7f2cc7c 33/90: counsel.el: Add a bunch of autoload cookies, Oleh Krehel, 2015/06/30
- [elpa] master 165c176 34/90: counsel.el (counsel-find-file-ignore-regexp): Default to nil, Oleh Krehel, 2015/06/30
- [elpa] master 72d4c76 35/90: Replace "C-x 6" with "<f2>" in counsel-M-x, Oleh Krehel, 2015/06/30
- [elpa] master 8c3bf21 36/90: ivy-toggle-calling: Toggle calling "RET" action for current candidate, Oleh Krehel, 2015/06/30
- [elpa] master 39eb7ed 38/90: counsel.el (counsel-M-x): Call smex-initialize, Oleh Krehel, 2015/06/30
- [elpa] master 109e5b0 37/90: Bind "C-o" to hydra-ivy/body, Oleh Krehel, 2015/06/30
- [elpa] master 7dea8b7 39/90: ivy.el (hydra-ivy/body): Autoload, Oleh Krehel, 2015/06/30
- [elpa] master 9ceb7ee 42/90: Fix yank/undo bug, Oleh Krehel, 2015/06/30
- [elpa] master d8172a0 40/90: ivy.el (ivy--regex-fuzzy): Improve for "^" and "$",
Oleh Krehel <=
- [elpa] master 02cedb7 43/90: ivy.el (ivy-insert-current): Add and bind to "M-i", Oleh Krehel, 2015/06/30
- [elpa] master 1a5b259 44/90: Fix the minibuffer being too small with enough candidates, Oleh Krehel, 2015/06/30
- [elpa] master e334a75 45/90: ivy.el (ivy-initial-inputs-alist): Add man and woman, Oleh Krehel, 2015/06/30
- [elpa] master ae05765 41/90: Allow to customize the initial input for all commands, Oleh Krehel, 2015/06/30
- [elpa] master 4d66758 47/90: Allow to toggle matching mode with "C-o m", Oleh Krehel, 2015/06/30
- [elpa] master 16fefbc 48/90: ivy-hydra.el (hydra-ivy): Add "C-j" and "C-m" exit points, Oleh Krehel, 2015/06/30
- [elpa] master 7945ab0 49/90: counsel.el (counsel-M-x): Call smex-rank, Oleh Krehel, 2015/06/30
- [elpa] master 76897c0 46/90: ivy.el (ivy-sort-functions-alist): Work for commands as well, Oleh Krehel, 2015/06/30
- [elpa] master 61bb9e0 50/90: Require TRAMP in time, Oleh Krehel, 2015/06/30
- [elpa] master 9df660c 51/90: swiper.el (swiper-query-replace): Don't miss the first, Oleh Krehel, 2015/06/30