]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge ivy--persistent-action into ivy-state-action
authorOleh Krehel <ohwoeowho@gmail.com>
Fri, 1 May 2015 20:44:57 +0000 (22:44 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Fri, 1 May 2015 20:44:57 +0000 (22:44 +0200)
* counsel.el (counsel-git-grep): Update.

* ivy.el (ivy--persistent-action): Remove defvar.
(ivy-next-line-and-call): Update.
(ivy-previous-line-and-call): Update.

counsel.el
ivy.el

index daa05b99351d35f72320aab6183002b2ea95755d..7ee63fc573a62e2e3b0c78b68c77e2148be4275b 100644 (file)
                                       default-directory ".git"))
               (counsel--git-grep-count (counsel-git-grep-count ""))
               (ivy--dynamic-function (when (> counsel--git-grep-count 20000)
-                                       'counsel-git-grep-function))
-              (ivy--persistent-action (lambda (x)
-                                        (let ((lst (split-string x ":")))
-                                          (find-file (expand-file-name (car lst) counsel--git-grep-dir))
-                                          (goto-char (point-min))
-                                          (forward-line (1- (string-to-number (cadr lst))))
-                                          (setq swiper--window (selected-window))
-                                          (swiper--cleanup)
-                                          (swiper--add-overlays (ivy--regex ivy-text)))))
-              (val (ivy-read "pattern: " 'counsel-git-grep-function
-                             :initial-input initial-input)))
-         (when val
-           (funcall ivy--persistent-action val)))
+                                       'counsel-git-grep-function)))
+         (ivy-read "pattern: " 'counsel-git-grep-function
+                   :initial-input initial-input
+                   :action
+                   (lambda ()
+                     (let ((lst (split-string ivy--current ":")))
+                       (find-file (expand-file-name (car lst) counsel--git-grep-dir))
+                       (goto-char (point-min))
+                       (forward-line (1- (string-to-number (cadr lst))))
+                       (setq swiper--window (selected-window))
+                       (swiper--cleanup)
+                       (swiper--add-overlays (ivy--regex ivy-text))))))
     (swiper--cleanup)))
 
 (defun counsel-locate-function (str &rest _u)
diff --git a/ivy.el b/ivy.el
index 49568d505fc0aee89ed9423d8530d3b97290f214..05509f8de440435a24c2f2ee62f3972b740f3084 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -157,9 +157,6 @@ of `history-length', which see.")
   "Store 'done if the completion was successfully selected.
 Otherwise, store nil.")
 
-(defvar ivy--persistent-action nil
-  "Store a function to call for current candidate without exiting.")
-
 (defvar ivy--all-candidates nil
   "Store the candidates passed to `ivy-read'.")
 
@@ -378,18 +375,16 @@ If the input is empty, select the previous history element instead."
   (interactive "p")
   (ivy-next-line arg)
   (ivy--exhibit)
-  (when ivy--persistent-action
-    (with-selected-window (ivy-state-window ivy-last)
-      (funcall ivy--persistent-action ivy--current))))
+  (with-selected-window (ivy-state-window ivy-last)
+    (funcall (ivy-state-action ivy-last))))
 
 (defun ivy-previous-line-and-call (&optional arg)
   "Move cursor vertically down ARG candidates."
   (interactive "p")
   (ivy-previous-line arg)
   (ivy--exhibit)
-  (when ivy--persistent-action
-    (with-selected-window (ivy-state-window ivy-last)
-      (funcall ivy--persistent-action ivy--current))))
+  (with-selected-window (ivy-state-window ivy-last)
+    (funcall (ivy-state-action ivy-last))))
 
 (defun ivy-previous-history-element (arg)
   "Forward to `previous-history-element' with ARG."