emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action


From: Oleh Krehel
Subject: [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action
Date: Tue, 08 Dec 2015 10:50:29 +0000

branch: master
commit 8fdf210c2da544ee8d6b917c438011540e10b8bb
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Switch to using ivy-exit-with-action
    
    * ivy.el (ivy-exit-with-action): Add a missing quote.
    (ivy--cd-maybe): Use `ivy-exit-with-action'.
    
    * counsel.el (counsel-find-symbol):
    (counsel--info-lookup-symbol):
    (counsel-git-grep-query-replace): Use `ivy-exit-with-action'.
    
    * swiper.el (swiper-query-replace):
    (swiper-mc): Use `ivy-exit-with-action'.
    
    The previous approach was overwriting the action list, so when
    `ivy-resume' was called, only a single action was present.  The new
    approach doesn't have this bug.
    
    So now it's possible to e.g. `counsel-describe-function' -> "M-o d" ->
    `ivy-resume' -> "M-o o" -> `ivy-resume' -> "M-o i".
---
 counsel.el |   12 ++++--------
 ivy.el     |   11 ++++-------
 swiper.el  |   19 ++++++++-----------
 3 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/counsel.el b/counsel.el
index 9b208c7..bee493b 100644
--- a/counsel.el
+++ b/counsel.el
@@ -159,14 +159,12 @@
 (defun counsel-find-symbol ()
   "Jump to the definition of the current symbol."
   (interactive)
-  (ivy-set-action #'counsel--find-symbol)
-  (ivy-done))
+  (ivy-exit-with-action #'counsel--find-symbol))
 
 (defun counsel--info-lookup-symbol ()
   "Lookup the current symbol in the info docs."
   (interactive)
-  (ivy-set-action #'counsel-info-lookup-symbol)
-  (ivy-done))
+  (ivy-exit-with-action #'counsel-info-lookup-symbol))
 
 (defun counsel--find-symbol (x)
   "Find symbol definition that corresponds to string X."
@@ -392,7 +390,7 @@
     (let* ((enable-recursive-minibuffers t)
            (from (ivy--regex ivy-text))
            (to (query-replace-read-to from "Query replace" t)))
-      (ivy-set-action
+      (ivy-exit-with-action
        (lambda (_)
          (let (done-buffers)
            (dolist (cand ivy--old-cands)
@@ -404,9 +402,7 @@
                      (push file-name done-buffers)
                      (find-file file-name)
                      (goto-char (point-min)))
-                   (perform-replace from to t t nil))))))))
-      (setq ivy-exit 'done)
-      (exit-minibuffer))))
+                   (perform-replace from to t t nil)))))))))))
 
 (defun counsel-git-grep-recenter ()
   (interactive)
diff --git a/ivy.el b/ivy.el
index fe2d125..7f79406 100644
--- a/ivy.el
+++ b/ivy.el
@@ -285,7 +285,7 @@ When non-nil, it should contain one %d.")
   "Quit the minibuffer and call ACTION afterwards."
   (ivy-set-action
    `(lambda (x)
-      (funcall ,action x)
+      (funcall ',action x)
       (ivy-set-action ',(ivy-state-action ivy-last))))
   (setq ivy-exit 'done)
   (exit-minibuffer))
@@ -736,12 +736,9 @@ If so, move to that directory, while keeping only the file 
name."
     (let ((input (ivy--input))
           url)
       (if (setq url (ffap-url-p input))
-          (progn
-            (ivy-set-action
-             (lambda (_)
-               (funcall ffap-url-fetcher url)))
-            (setq ivy-exit 'done)
-            (exit-minibuffer))
+          (ivy-exit-with-action
+           (lambda (_)
+             (funcall ffap-url-fetcher url)))
         (setq input (expand-file-name input))
         (let ((file (file-name-nondirectory input))
               (dir (expand-file-name (file-name-directory input))))
diff --git a/swiper.el b/swiper.el
index f2fe31f..b504f19 100644
--- a/swiper.el
+++ b/swiper.el
@@ -105,14 +105,13 @@
     (let* ((enable-recursive-minibuffers t)
            (from (ivy--regex ivy-text))
            (to (query-replace-read-to from "Query replace" t)))
-      (delete-minibuffer-contents)
-      (ivy-set-action (lambda (_)
-                        (with-ivy-window
-                          (move-beginning-of-line 1)
-                          (perform-replace from to
-                                           t t nil))))
       (swiper--cleanup)
-      (exit-minibuffer))))
+      (ivy-exit-with-action
+       (lambda (_)
+         (with-ivy-window
+           (move-beginning-of-line 1)
+           (perform-replace from to
+                            t t nil)))))))
 
 (defvar avy-background)
 (defvar avy-all-windows)
@@ -185,16 +184,14 @@
     (error "multiple-cursors isn't installed"))
   (let ((cands (nreverse ivy--old-cands)))
     (unless (string= ivy-text "")
-      (ivy-set-action
+      (ivy-exit-with-action
        (lambda (_)
          (let (cand)
            (while (setq cand (pop cands))
              (swiper--action cand)
              (when cands
                (mc/create-fake-cursor-at-point))))
-         (multiple-cursors-mode 1)))
-      (setq ivy-exit 'done)
-      (exit-minibuffer))))
+         (multiple-cursors-mode 1))))))
 
 (defun swiper-recenter-top-bottom (&optional arg)
   "Call (`recenter-top-bottom' ARG)."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]