[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d0b6e94 02/12: Allow to quote spaces while matching
From: |
Oleh Krehel |
Subject: |
[elpa] master d0b6e94 02/12: Allow to quote spaces while matching |
Date: |
Sun, 03 May 2015 11:04:50 +0000 |
branch: master
commit d0b6e946fe0f83d1cfb644fda413b61af40541fd
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to quote spaces while matching
* ivy.el (ivy--split): New defun.
Use (ivy--split str) in place of (split-string str " +" t).
Allows to "quote" N spaces by inputting N+1 spaces.
---
ivy.el | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/ivy.el b/ivy.el
index eb0a8b6..307c989 100644
--- a/ivy.el
+++ b/ivy.el
@@ -722,6 +722,24 @@ Turning on Ivy mode will set `completing-read-function' to
(make-hash-table :test 'equal)
"Store pre-computed regex.")
+(defun ivy--split (str)
+ "Split STR into a list by single spaces.
+The remaining spaces stick to their left.
+This allows to \"quote\" N spaces by inputting N+1 spaces."
+ (let ((len (length str))
+ (start 0)
+ res s)
+ (while (and (string-match " +" str start)
+ (< start len))
+ (setq s (substring str start (1- (match-end 0))))
+ (unless (= (length s) 0)
+ (push s res))
+ (setq start (match-end 0)))
+ (setq s (substring str start))
+ (unless (= (length s) 0)
+ (push s res))
+ (nreverse res)))
+
(defun ivy--regex (str &optional greedy)
"Re-build regex from STR in case it has a space.
When GREEDY is non-nil, join words in a greedy way."
@@ -731,7 +749,7 @@ When GREEDY is non-nil, join words in a greedy way."
(prog1 (cdr hashed)
(setq ivy--subexps (car hashed)))
(cdr (puthash str
- (let ((subs (split-string str " +" t)))
+ (let ((subs (ivy--split str)))
(if (= (length subs) 1)
(cons
(setq ivy--subexps 0)
- [elpa] master updated (69bf1bd -> 34753b4), Oleh Krehel, 2015/05/03
- [elpa] master 0353b9f 01/12: Add ivy-state struct, Oleh Krehel, 2015/05/03
- [elpa] master 0210bb6 03/12: Merge ivy-def into ivy-last, Oleh Krehel, 2015/05/03
- [elpa] master d0b6e94 02/12: Allow to quote spaces while matching,
Oleh Krehel <=
- [elpa] master 7f63f09 04/12: Merge ivy-window into ivy-last, Oleh Krehel, 2015/05/03
- [elpa] master 00d1c95 06/12: ivy-resume now works for functions that supply action, Oleh Krehel, 2015/05/03
- [elpa] master cdafe1b 05/12: Merge ivy--action into ivy-last, Oleh Krehel, 2015/05/03
- [elpa] master 2bc08de 07/12: Merge ivy--persistent-action into ivy-state-action, Oleh Krehel, 2015/05/03
- [elpa] master 2e046d1 09/12: Fix the candidate index for `ivy-resume', Oleh Krehel, 2015/05/03
- [elpa] master 109fb7d 08/12: Add unwind argument to ivy-read, Oleh Krehel, 2015/05/03
- [elpa] master b5332c5 10/12: ivy.el (ivy-resume): Quote the preselect, Oleh Krehel, 2015/05/03
- [elpa] master 829bdb6 11/12: swiper.el: Bump version, Oleh Krehel, 2015/05/03
- [elpa] master 34753b4 12/12: Merge commit '829bdb6dcb08e2b1a8d8c329e697156e5fa2dbcc' from swiper, Oleh Krehel, 2015/05/03