[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 65cf724 247/272: Make ivy--regex work with "[^ ]"
From: |
Oleh Krehel |
Subject: |
[elpa] master 65cf724 247/272: Make ivy--regex work with "[^ ]" |
Date: |
Mon, 25 Apr 2016 10:13:28 +0000 |
branch: master
commit 65cf72467e45474595ceb2519a9e3fd5b411e541
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make ivy--regex work with "[^ ]"
* ivy.el (ivy--split): Add a work around to not consider spaces like
"[^ ]". It's pretty hacky, the space has to come right after "[^".
But better than nothing.
* ivy-test.el (ivy--split): Add test.
Use-case: open a freedict file, where each word being defined is with no
indentation and the explanation is with indentation.
`swiper' or `counsel-grep' will now work properly with input "^[^ ]".
---
ivy-test.el | 6 ++++--
ivy.el | 32 ++++++++++++++++++++------------
2 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index a654ad6..5e388d3 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -107,8 +107,10 @@
'("Who are" "the Brittons?")))
(should (equal (ivy--split "We're all Britons and I am your king.")
'("We're all Britons"
- "and I am"
- "your king."))))
+ "and I am"
+ "your king.")))
+ (should (equal (ivy--split "^[^ ]") '("^[^ ]")))
+ (should (equal (ivy--split "^[^ ] bar") '("^[^ ]" "bar"))))
(ert-deftest ivy--regex ()
(should (equal (ivy--regex
diff --git a/ivy.el b/ivy.el
index 53d0622..ba76632 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1680,19 +1680,27 @@ This allows to \"quote\" N spaces by inputting N+1
spaces."
match-len)
(while (and (string-match " +" str start1)
(< start1 len))
- (setq match-len (- (match-end 0) (match-beginning 0)))
- (if (= match-len 1)
+ (if (and (> (match-beginning 0) 2)
+ (string= "[^" (substring
+ str
+ (- (match-beginning 0) 2)
+ (match-beginning 0))))
(progn
- (when start0
- (setq start1 start0)
- (setq start0 nil))
- (push (substring str start1 (match-beginning 0)) res)
- (setq start1 (match-end 0)))
- (setq str (replace-match
- (make-string (1- match-len) ?\ )
- nil nil str))
- (setq start0 (or start0 start1))
- (setq start1 (1- (match-end 0)))))
+ (setq start1 (match-end 0))
+ (setq start0 0))
+ (setq match-len (- (match-end 0) (match-beginning 0)))
+ (if (= match-len 1)
+ (progn
+ (when start0
+ (setq start1 start0)
+ (setq start0 nil))
+ (push (substring str start1 (match-beginning 0)) res)
+ (setq start1 (match-end 0)))
+ (setq str (replace-match
+ (make-string (1- match-len) ?\ )
+ nil nil str))
+ (setq start0 (or start0 start1))
+ (setq start1 (1- (match-end 0))))))
(if start0
(push (substring str start0) res)
(setq s (substring str start1))
- [elpa] master 1088078 266/272: When selecting a non-existing key in an alist, return that key, (continued)
- [elpa] master 1088078 266/272: When selecting a non-existing key in an alist, return that key, Oleh Krehel, 2016/04/25
- [elpa] master 341b5a2 229/272: counsel-grep should pick candidates closest to point, Oleh Krehel, 2016/04/25
- [elpa] master d71b5c5 081/272: swiper.el (swiper--action): Update regexp-search-ring, Oleh Krehel, 2016/04/25
- [elpa] master e1c156b 074/272: ivy.el (ivy--resize-minibuffer-to-fit): Check frame-root-window-p, Oleh Krehel, 2016/04/25
- [elpa] master ebd3e29 089/272: swiper.el (swiper--update-input-ivy): Fix a bug, Oleh Krehel, 2016/04/25
- [elpa] master de0e541 234/272: Speed up counsel-grep by up to 40 times, Oleh Krehel, 2016/04/25
- [elpa] master 299bc13 097/272: Fix initial-input not set to nil for 'read-file-name-internal, Oleh Krehel, 2016/04/25
- [elpa] master bab5aab 269/272: doc/Changelog.org: Prepare for the 0.8.0 release, Oleh Krehel, 2016/04/25
- [elpa] master 0efbf6e 055/272: Simplify the signature for :dynamic-collection functions, Oleh Krehel, 2016/04/25
- [elpa] master 6a5a688 201/272: counsel.el: Improve counsel-grep, Oleh Krehel, 2016/04/25
- [elpa] master 65cf724 247/272: Make ivy--regex work with "[^ ]",
Oleh Krehel <=
- [elpa] master f72cea2 253/272: swiper.el (swiper-mc): Restore interactive, Oleh Krehel, 2016/04/25
- [elpa] master 08d5578 137/272: counsel.el (counsel-git-log): New command, Oleh Krehel, 2016/04/25
- [elpa] master 00f08f7 073/272: Improve Ivy documentation UI, Oleh Krehel, 2016/04/25
- [elpa] master 8f527d7 149/272: ivy.el (ivy-next-history-element): No "\\_<" for dynamic-collection, Oleh Krehel, 2016/04/25
- [elpa] master 265bf49 251/272: counsel.el: Fix compile warning, Oleh Krehel, 2016/04/25
- [elpa] master 7cf13a7 186/272: counsel.el (counsel-linux-app): New command, Oleh Krehel, 2016/04/25
- [elpa] master 31a2f86 238/272: counsel.el (counsel-expression-history): enable-recursive-minibuffers, Oleh Krehel, 2016/04/25
- [elpa] master 5299c0a 099/272: doc/ivy.texi: Re-export from previous commit, Oleh Krehel, 2016/04/25
- [elpa] master a50f668 111/272: counsel.el (counsel-locate-options): Make obsolete, Oleh Krehel, 2016/04/25
- [elpa] master 327b85a 239/272: counsel.el (counsel-expression-history): Add docstring, Oleh Krehel, 2016/04/25