[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e32bc63 46/67: swiper.el: Fix non-matching lines issue wit
From: |
Oleh Krehel |
Subject: |
[elpa] master e32bc63 46/67: swiper.el: Fix non-matching lines issue with initial-input |
Date: |
Sun, 22 Mar 2015 17:34:05 +0000 |
branch: master
commit e32bc6320629f3bff57722e8bd65b6b5eaf134c1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el: Fix non-matching lines issue with initial-input
* swiper.el (swiper--index-at-point): New defun.
(swiper--ivy): Update.
Fixes #20.
---
swiper.el | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/swiper.el b/swiper.el
index 6d889dd..e00aa1a 100644
--- a/swiper.el
+++ b/swiper.el
@@ -134,19 +134,42 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(setq swiper--anchor (line-number-at-pos))
(setq swiper--window (selected-window)))
+(defun swiper--index-at-point (candidates initial-input)
+ "Return the index of current line in CANDIDATES filtered by INITIAL-INPUT."
+ (cl-position-if
+ `(lambda (x)
+ (string-match
+ ,(format
+ "[0-9]+ *%s"
+ (regexp-quote
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
+ x))
+ (cl-remove-if-not
+ (lambda (x)
+ (string-match initial-input x))
+ candidates)))
+
(defun swiper--ivy (&optional initial-input)
"`isearch' with an overview using `ivy'.
When non-nil, INITIAL-INPUT is the initial search pattern."
(interactive)
(ido-mode -1)
(swiper--init)
- (let (res)
+ (let* ((candidates (swiper--candidates))
+ (index (if initial-input
+ (swiper--index-at-point
+ candidates initial-input)
+ (1-
+ (line-number-at-pos))))
+ res)
(unwind-protect
(setq res (ivy-read "pattern: "
- (swiper--candidates)
+ candidates
initial-input
#'swiper--update-input-ivy
- (1- (line-number-at-pos))))
+ index))
(ido-mode 1)
(swiper--cleanup)
(if (null ivy-exit)
- [elpa] master c78cc15 34/67: swiper.el: Clean up overlays better on "C-g", (continued)
- [elpa] master c78cc15 34/67: swiper.el: Clean up overlays better on "C-g", Oleh Krehel, 2015/03/22
- [elpa] master e7b560c 38/67: swiper.el (swiper--opoint): Fix bad defvar, Oleh Krehel, 2015/03/22
- [elpa] master d78caee 33/67: Open invisible overlays using isearch, Oleh Krehel, 2015/03/22
- [elpa] master 8818a01 36/67: swiper.el: Fix error for empty buffer, Oleh Krehel, 2015/03/22
- [elpa] master 984346c 40/67: swiper.el (swiper-font-lock-ensure): Exclude a few modes, Oleh Krehel, 2015/03/22
- [elpa] master cb26121 41/67: ivy.el: Fix ivy-history recording the full text instead of input, Oleh Krehel, 2015/03/22
- [elpa] master de80846 39/67: Work around magit highlighting problem, Oleh Krehel, 2015/03/22
- [elpa] master 7bb5320 42/67: swiper.el (swiper--helm): Require helm-match-plugin, Oleh Krehel, 2015/03/22
- [elpa] master caa69f2 43/67: counsel.el: Add git file completion, Oleh Krehel, 2015/03/22
- [elpa] master fcb18e5 44/67: ivy.el (ivy-read): Bring last history candidate to front, Oleh Krehel, 2015/03/22
- [elpa] master e32bc63 46/67: swiper.el: Fix non-matching lines issue with initial-input,
Oleh Krehel <=
- [elpa] master f1672c7 45/67: Add isearch-like history behavior, Oleh Krehel, 2015/03/22
- [elpa] master 41732be 48/67: ivy.el: Return nil when there is no match, Oleh Krehel, 2015/03/22
- [elpa] master 588dab6 49/67: ivy-test.el: Add testing, Oleh Krehel, 2015/03/22
- [elpa] master f754835 47/67: swiper.el: Silence a few compilation warnings, Oleh Krehel, 2015/03/22
- [elpa] master cc4bf75 52/67: README.md: Add build status, Oleh Krehel, 2015/03/22
- [elpa] master 2b8e4e1 53/67: ivy.el: Remove while-no-input, Oleh Krehel, 2015/03/22
- [elpa] master 2191bdb 54/67: ivy.el (ivy-completions): Simplify, Oleh Krehel, 2015/03/22
- [elpa] master d587fa2 51/67: ivy.el (ivy-read): Allow for format-style PROMPT, Oleh Krehel, 2015/03/22
- [elpa] master 9f9c4dc 57/67: swiper-helm.el: Fix typo, Oleh Krehel, 2015/03/22
- [elpa] master 3a08a88 50/67: ivy.el (ivy-read): Change index to preselect, Oleh Krehel, 2015/03/22