[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e0b6c0c 46/57: Update the way spaces are quoted using ivy
From: |
Oleh Krehel |
Subject: |
[elpa] master e0b6c0c 46/57: Update the way spaces are quoted using ivy |
Date: |
Tue, 19 May 2015 14:21:39 +0000 |
branch: master
commit e0b6c0ce773ebf3480104e6e4860365973f4e29b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Update the way spaces are quoted using ivy
* ivy.el (ivy--split): Split only on single spaces. From all other space
groups, remove one space.
* ivy-test.el (ivy--split): Add test.
Fixes #109
---
ivy-test.el | 12 ++++++++++++
ivy.el | 30 +++++++++++++++++++++---------
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 951bfda..91e0dc3 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -69,3 +69,15 @@
"^[0-9][0-9 ]\\{4\\}\\(a\\)"))
(should (string= (swiper--re-builder "^a b")
"^[0-9][0-9 ]\\{4\\}\\(a\\).*?\\(b\\)")))
+
+(ert-deftest ivy--split ()
+ (should (equal (ivy--split "King of the who?")
+ '("King" "of" "the" "who?")))
+ (should (equal (ivy--split "The Brittons.")
+ '("The Brittons.")))
+ (should (equal (ivy--split "Who are the Brittons?")
+ '("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."))))
diff --git a/ivy.el b/ivy.el
index 121e8f5..c0bbedb 100644
--- a/ivy.el
+++ b/ivy.el
@@ -801,17 +801,29 @@ Minibuffer bindings:
The remaining spaces stick to their left.
This allows to \"quote\" N spaces by inputting N+1 spaces."
(let ((len (length str))
- (start 0)
+ start0
+ (start1 0)
res s)
- (while (and (string-match " +" str start)
- (< start len))
- (setq s (substring str start (1- (match-end 0))))
+ (while (and (string-match " +" str start1)
+ (< start1 len))
+ (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))
(unless (= (length s) 0)
- (push s res))
- (setq start (match-end 0)))
- (setq s (substring str start))
- (unless (= (length s) 0)
- (push s res))
+ (push s res)))
(nreverse res)))
(defun ivy--regex (str &optional greedy)
- [elpa] master 1cdb6ed 32/57: ivy.el (ivy-partial-or-done): Fixup, (continued)
- [elpa] master 1cdb6ed 32/57: ivy.el (ivy-partial-or-done): Fixup, Oleh Krehel, 2015/05/19
- [elpa] master 5f2cf0c 28/57: Update test, Oleh Krehel, 2015/05/19
- [elpa] master 6405cb3 42/57: ivy.el (ivy-partial-or-done): Always forward to `ivy-alt-done', Oleh Krehel, 2015/05/19
- [elpa] master 10f9954 50/57: counsel.el (counsel-git-grep): Warn if not in a repository, Oleh Krehel, 2015/05/19
- [elpa] master 2cedcf5 37/57: Introduce :matcher for counsel-git-grep, Oleh Krehel, 2015/05/19
- [elpa] master 93faef3 41/57: ivy.el (ivy-delete-char): Add and bind to "C-d", Oleh Krehel, 2015/05/19
- [elpa] master 8630048 47/57: Fixed ivy--preselect-index on windows where the drives folders ends with a backslash (C:\, D:\), Oleh Krehel, 2015/05/19
- [elpa] master 1c0703e 36/57: Forward to minibuffer-complete for filenames only if "^/", Oleh Krehel, 2015/05/19
- [elpa] master 70c8c8a 40/57: ivy.el (ivy-switch-buffer): Preselect other-buffer, Oleh Krehel, 2015/05/19
- [elpa] master 9da8e53 54/57: counsel.el (counsel-info-lookup-symbol): Turn on sorting, Oleh Krehel, 2015/05/19
- [elpa] master e0b6c0c 46/57: Update the way spaces are quoted using ivy,
Oleh Krehel <=
- [elpa] master 323efda 38/57: counsel-git-grep now works with ivy-resume, Oleh Krehel, 2015/05/19
- [elpa] master 88f4508 49/57: ivy.el (ivy-kill-word): Add and bind to "M-d", Oleh Krehel, 2015/05/19
- [elpa] master de5833e 51/57: Don't error on incomplete bad regexp in counsel-git-grep, Oleh Krehel, 2015/05/19
- [elpa] master 89b9e9a 48/57: README.md: Add sample init, Oleh Krehel, 2015/05/19
- [elpa] master 28cb795 53/57: Don't try to call permanent action if there's none, Oleh Krehel, 2015/05/19
- [elpa] master 75a059c 44/57: Allow to recenter with "C-l" during counsel-git-grep, Oleh Krehel, 2015/05/19
- [elpa] master 4f75381 55/57: When building a regex, consider ^ only at start, Oleh Krehel, 2015/05/19
- [elpa] master 5afceff 52/57: ivy.el (ivy-forward-char): Add and bind to "C-f", Oleh Krehel, 2015/05/19
- [elpa] master 155f2a6 57/57: Merge commit 'bc335af4d94d80d3605b66ed51a15d2476ad2179' from swiper, Oleh Krehel, 2015/05/19
- [elpa] master bc335af 56/57: Fixup compilation warnings, Oleh Krehel, 2015/05/19