[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one")
From: |
Oleh Krehel |
Subject: |
[elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one") |
Date: |
Tue, 08 Dec 2015 10:50:31 +0000 |
branch: master
commit d9ecd2e6d4b36201bb57b177a51b84cb7e71a1f3
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix the preselect for (swiper "one")
* ivy.el (ivy--reset-state): Ignore INITIAL-INPUT on the first
step. Then all `ivy--filter' on the second step.
(ivy--preselect-index): Change arglist. No longer takes INITIAL-INPUT.
(ivy--recompute-index): Update the call to `ivy--preselect-index'.
Fixes #292
---
ivy.el | 31 +++++++++----------------------
1 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/ivy.el b/ivy.el
index 9eafaa6..9004477 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1121,8 +1121,7 @@ This is useful for recursive `ivy-read'."
(re-builder (ivy-state-re-builder state))
(dynamic-collection (ivy-state-dynamic-collection state))
(initial-input (ivy-state-initial-input state))
- (require-match (ivy-state-require-match state))
- (matcher (ivy-state-matcher state)))
+ (require-match (ivy-state-require-match state)))
(unless initial-input
(setq initial-input (cdr (assoc this-command
ivy-initial-inputs-alist))))
@@ -1199,11 +1198,14 @@ This is useful for recursive `ivy-read'."
(and dynamic-collection
ivy--index)
(and preselect
- (ivy--preselect-index
- coll initial-input preselect matcher))
+ (ivy--preselect-index preselect coll))
0))
(setq ivy--old-re nil)
(setq ivy--old-cands nil)
+ (when initial-input
+ ;; Needed for anchor to work
+ (setq ivy--old-cands coll)
+ (setq ivy--old-cands (ivy--filter initial-input coll)))
(setq ivy--all-candidates coll))
(setq ivy-exit nil)
(setq ivy--default (or
@@ -1300,21 +1302,8 @@ Minibuffer bindings:
(setq completing-read-function 'ivy-completing-read)
(setq completing-read-function 'completing-read-default)))
-(defun ivy--preselect-index (candidates initial-input preselect matcher)
- "Return the index in CANDIDATES filtered by INITIAL-INPUT for PRESELECT.
-When MATCHER is non-nil it's used instead of `cl-remove-if-not'."
- (if initial-input
- (progn
- (setq initial-input (ivy--regex-plus initial-input))
- (setq candidates
- (if matcher
- (funcall matcher initial-input candidates)
- (cl-remove-if-not
- (lambda (x)
- (string-match initial-input x))
- candidates))))
- (when matcher
- (setq candidates (funcall matcher "" candidates))))
+(defun ivy--preselect-index (preselect candidates)
+ "Return the index of PRESELECT in CANDIDATES."
(cond ((integerp preselect)
preselect)
((cl-position preselect candidates :test #'equal))
@@ -1821,10 +1810,8 @@ Prefix matches to NAME are put ahead of the list."
(not (equal ivy--old-re "")))
(setq ivy--index
(or (ivy--preselect-index
- cands
- nil
(ivy-state-preselect ivy-last)
- nil)
+ cands)
ivy--index)))))
(defun ivy-recompute-index-swiper (_re-str cands)
- [elpa] master 63f3498 123/167: Add precise preselect for swiper with visual-line-mode, (continued)
- [elpa] master 63f3498 123/167: Add precise preselect for swiper with visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 74bb138 144/167: Update ivy format functions., Oleh Krehel, 2015/12/08
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, Oleh Krehel, 2015/12/08
- [elpa] master 63e714c 130/167: Allow access to TRAMP from "// C-j", Oleh Krehel, 2015/12/08
- [elpa] master 85bd44b 125/167: swiper.el: Modify the behavior with org-mode and visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action, Oleh Krehel, 2015/12/08
- [elpa] master ce6ab7a 135/167: Perform string-match in the original buffer, Oleh Krehel, 2015/12/08
- [elpa] master bc00eaf 137/167: Fix `counsel-ag` on Windows, Oleh Krehel, 2015/12/08
- [elpa] master ed2367b 134/167: swiper.el (swiper--candidates): Require outline, Oleh Krehel, 2015/12/08
- [elpa] master 80d4dde 141/167: Fix broken candidate index in ivy-resume, Oleh Krehel, 2015/12/08
- [elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one"),
Oleh Krehel <=
- [elpa] master 073b071 115/167: Allow to sort files by last modification time., Oleh Krehel, 2015/12/08
- [elpa] master 0c62f7e 132/167: ivy.el (ivy-alt-done): Split into smaller defuns, Oleh Krehel, 2015/12/08
- [elpa] master 59df2e9 131/167: ivy.el (ivy-alt-done): Refactor, Oleh Krehel, 2015/12/08
- [elpa] master 2bec99d 146/167: Ease production of functions like ivy-format-function-default, Oleh Krehel, 2015/12/08
- [elpa] master c546ae4 150/167: Enable recursive swiper calls, Oleh Krehel, 2015/12/08
- [elpa] master 1bf4ae2 140/167: Warn the user about the behavior of ivy--regex-ignore-order, Oleh Krehel, 2015/12/08
- [elpa] master 99d214d 142/167: Ivy-resume should restore the buffer for swiper, Oleh Krehel, 2015/12/08
- [elpa] master 8abed59 143/167: Add counsel-grep, Oleh Krehel, 2015/12/08
- [elpa] master 3b67044 145/167: Convert ivy formatting functions to dotted pairs., Oleh Krehel, 2015/12/08
- [elpa] master ac09f6b 152/167: Fix the issue caused by recursive swiper calls, Oleh Krehel, 2015/12/08