]> code.delx.au - gnu-emacs-elpa/commitdiff
Switch to using ivy-exit-with-action
authorOleh Krehel <ohwoeowho@gmail.com>
Wed, 18 Nov 2015 10:55:45 +0000 (11:55 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 18 Nov 2015 11:08:57 +0000 (12:08 +0100)
* 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
ivy.el
swiper.el

index 9b208c7b3a2da28a28b9bf1a00de4c2b5bee77ff..bee493bacba44c7ff79e3f1776886dfa69e3963e 100644 (file)
 (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."
     (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)
                      (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 fe2d125568327266c6ff2fbb15e6bd1d7df0ed97..7f7940635dba9ed3e3d6238c1527b94546c9ed10 100644 (file)
--- 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))))
index f2fe31f04357ccb2603ac2f26c242f8eee5d4c25..b504f19de229c1aea7e13760a364d52a5ca7122e 100644 (file)
--- a/swiper.el
+++ b/swiper.el
     (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)
     (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)."