[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 109fb7d 08/12: Add unwind argument to ivy-read
From: |
Oleh Krehel |
Subject: |
[elpa] master 109fb7d 08/12: Add unwind argument to ivy-read |
Date: |
Sun, 03 May 2015 11:04:54 +0000 |
branch: master
commit 109fb7decd31f026c21ee5f7f607d3c8ad15c1c1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add unwind argument to ivy-read
* ivy.el (ivy-state): Add `unwind' field.
(ivy-resume): Update.
(ivy-read): Call the `unwind' argument in the unwind form.
* swiper.el (swiper--ivy): Use `unwind' for `ivy-read'.
---
ivy.el | 25 +++++++++++++++++--------
swiper.el | 4 ++--
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/ivy.el b/ivy.el
index 05509f8..667186e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -124,7 +124,8 @@ Only \"./\" and \"../\" apply here. They appear in reverse
order."
history preselect keymap update-fn sort
;; The window in which `ivy-read' was called
window
- action)
+ action
+ unwind)
(defvar ivy-last nil
"The last parameters passed to `ivy-read'.")
@@ -310,7 +311,8 @@ candidate."
:keymap (ivy-state-keymap ivy-last)
:update-fn (ivy-state-update-fn ivy-last)
:sort (ivy-state-sort ivy-last)
- :action (ivy-state-action ivy-last)))
+ :action (ivy-state-action ivy-last)
+ :unwind (ivy-state-unwind ivy-last)))
(defun ivy-beginning-of-buffer ()
"Select the first completion candidate."
@@ -511,9 +513,9 @@ Directories come first."
;;** Entry Point
(cl-defun ivy-read (prompt collection
- &key predicate require-match initial-input
- history preselect keymap update-fn sort
- action)
+ &key predicate require-match initial-input
+ history preselect keymap update-fn sort
+ action unwind)
"Read a string in the minibuffer, with completion.
PROMPT is a string to prompt with; normally it ends in a colon
@@ -532,7 +534,11 @@ the ones that match INITIAL-INPUT.
UPDATE-FN is called each time the current candidate(s) is changed.
-When SORT is t, refer to `ivy-sort-functions-alist' for sorting."
+When SORT is t, refer to `ivy-sort-functions-alist' for sorting.
+
+ACTION is a lambda to call after a result was selected.
+
+UNWIND is a lambda to call before exiting."
(setq ivy-last
(make-ivy-state
:prompt prompt
@@ -546,7 +552,8 @@ When SORT is t, refer to `ivy-sort-functions-alist' for
sorting."
:update-fn update-fn
:sort sort
:action action
- :window (selected-window)))
+ :window (selected-window)
+ :unwind unwind))
(setq ivy--directory nil)
(setq ivy--regex-function
(or (and (functionp collection)
@@ -646,7 +653,9 @@ When SORT is t, refer to `ivy-sort-functions-alist' for
sorting."
(delete ivy-text
(cdr (symbol-value hist)))))
res)))
- (remove-hook 'post-command-hook #'ivy--exhibit))
+ (remove-hook 'post-command-hook #'ivy--exhibit)
+ (when (setq unwind (ivy-state-unwind ivy-last))
+ (funcall unwind)))
(when (setq action (ivy-state-action ivy-last))
(funcall action)))))
diff --git a/swiper.el b/swiper.el
index c727289..d77e96b 100644
--- a/swiper.el
+++ b/swiper.el
@@ -195,8 +195,8 @@ Please remove it and update the \"swiper\" package."))
:keymap swiper-map
:preselect preselect
:require-match t
- :update-fn #'swiper--update-input-ivy))
- (swiper--cleanup)
+ :update-fn #'swiper--update-input-ivy
+ :unwind #'swiper--cleanup))
(if (null ivy-exit)
(goto-char swiper--opoint)
(swiper--action res ivy-text)))))
- [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, 2015/05/03
- [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 <=
- [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