[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2fbcfb9 29/63: ivy.el (ivy--preselect-index): Add matcher
From: |
Oleh Krehel |
Subject: |
[elpa] master 2fbcfb9 29/63: ivy.el (ivy--preselect-index): Add matcher to arglist |
Date: |
Fri, 21 Aug 2015 12:08:38 +0000 |
branch: master
commit 2fbcfb970d060a895d8b5818e750a1143d0e24db
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy--preselect-index): Add matcher to arglist
* ivy.el (ivy--reset-state): Call `ivy--preselect-index' with matcher.
(ivy--preselect-index): In case there's a special matcher set, it
affects the candidate list, therefore it affects the preselect index.
Fixes #165
---
ivy.el | 29 ++++++++++++++++++-----------
1 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/ivy.el b/ivy.el
index bc26b6f..8e24f1f 100644
--- a/ivy.el
+++ b/ivy.el
@@ -893,7 +893,8 @@ 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)))
+ (require-match (ivy-state-require-match state))
+ (matcher (ivy-state-matcher state)))
(unless initial-input
(setq initial-input (cdr (assoc this-command
ivy-initial-inputs-alist))))
@@ -968,7 +969,7 @@ This is useful for recursive `ivy-read'."
ivy--index)
(and preselect
(ivy--preselect-index
- coll initial-input preselect))
+ coll initial-input preselect matcher))
0))
(setq ivy--old-re nil)
(setq ivy--old-cands nil)
@@ -1051,15 +1052,21 @@ Minibuffer bindings:
(setq completing-read-function 'ivy-completing-read)
(setq completing-read-function 'completing-read-default)))
-(defun ivy--preselect-index (candidates initial-input preselect)
- "Return the index in CANDIDATES filtered by INITIAL-INPUT for PRESELECT."
- (when initial-input
- (setq initial-input (ivy--regex-plus initial-input))
- (setq candidates
- (cl-remove-if-not
- (lambda (x)
- (string-match initial-input x))
- candidates)))
+(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))))
(or (cl-position preselect candidates :test #'equal)
(cl-position-if
(lambda (x)
- [elpa] master d289b78 15/63: Add a new interface to customize additional exit points, (continued)
- [elpa] master d289b78 15/63: Add a new interface to customize additional exit points, Oleh Krehel, 2015/08/21
- [elpa] master 1092e2d 24/63: swiper.el: Update avy--goto -> avy-action-goto, Oleh Krehel, 2015/08/21
- [elpa] master adad288 27/63: ivy.el (ivy-call): Add selected-window work-around for M-x, Oleh Krehel, 2015/08/21
- [elpa] master 9ca6f48 30/63: Allow "C-g" to interrupt ivy-dispatching-done, Oleh Krehel, 2015/08/21
- [elpa] master 5480079 28/63: ivy.el (ivy-dispatching-done): New command on "M-o", Oleh Krehel, 2015/08/21
- [elpa] master 6062903 21/63: ivy.el (ivy-count-format): Improve docstring, Oleh Krehel, 2015/08/21
- [elpa] master e91a4eb 31/63: ivy.el (ivy-dispatching-done): Display the candidate, Oleh Krehel, 2015/08/21
- [elpa] master 3464362 33/63: Add actions for counsel-describe-variable, Oleh Krehel, 2015/08/21
- [elpa] master 31d664a 32/63: ivy.el (ivy-dispatching-done): Add a trailing newline, Oleh Krehel, 2015/08/21
- [elpa] master 107ebff 34/63: Add actions for counsel-describe-function, Oleh Krehel, 2015/08/21
- [elpa] master 2fbcfb9 29/63: ivy.el (ivy--preselect-index): Add matcher to arglist,
Oleh Krehel <=
- [elpa] master cb0cf02 35/63: ivy.el (ivy-call): Remove with-selected-window, Oleh Krehel, 2015/08/21
- [elpa] master 08bd5b4 25/63: counsel.el (counsel-variable-list): Add, Oleh Krehel, 2015/08/21
- [elpa] master ae77d93 36/63: counsel.el (counsel-org-tag): Replace org-set-tags, Oleh Krehel, 2015/08/21
- [elpa] master 1e483c5 37/63: Fixup counsel-org-tag, Oleh Krehel, 2015/08/21
- [elpa] master a9ff1f1 38/63: counsel.el (counsel-org-change-tags): Improve removing tags, Oleh Krehel, 2015/08/21
- [elpa] master 5ae677c 41/63: Simplify counsel-git-grep logic, Oleh Krehel, 2015/08/21
- [elpa] master c1b9f5a 39/63: Allow "M-o j" to switch to virtual buffers in other window, Oleh Krehel, 2015/08/21
- [elpa] master f71a562 40/63: Fix "DEL" generating a "Quit" sometimes for counsel-git-grep, Oleh Krehel, 2015/08/21
- [elpa] master 36e8fe3 46/63: counsel.el (counsel-org-tag): No need to be at heading, Oleh Krehel, 2015/08/21
- [elpa] master acf4485 42/63: ivy.el (ivy--exhibit): Check if in post-command-hook, Oleh Krehel, 2015/08/21