]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/swiper/counsel.el
Merge commit '829bdb6dcb08e2b1a8d8c329e697156e5fa2dbcc' from swiper
[gnu-emacs-elpa] / packages / swiper / counsel.el
index 27825fe9d7ed3664eeba34d1eb223fe593e3fac0..7ee63fc573a62e2e3b0c78b68c77e2148be4275b 100644 (file)
@@ -48,9 +48,8 @@
 (defun counsel-find-symbol ()
   "Jump to the definition of the current symbol."
   (interactive)
-  (setq ivy--action 'counsel--find-symbol)
-  (setq ivy-exit 'done)
-  (exit-minibuffer))
+  (ivy-set-action 'counsel--find-symbol)
+  (ivy-done))
 
 (defun counsel--find-symbol ()
   (let ((sym (read ivy--current)))
 (defvar counsel-describe-symbol-history nil
   "History for `counsel-describe-variable' and `counsel-describe-function'.")
 
-(defun counsel-describe-variable (variable &optional buffer frame)
-  "Forward to (`describe-variable' VARIABLE BUFFER FRAME)."
-  (interactive
-   (let ((v (variable-at-point))
-         (enable-recursive-minibuffers t)
-         (preselect (thing-at-point 'symbol))
-         val)
-     (setq ivy--action nil)
-     (setq val (ivy-read
-                "Describe variable: "
-                (let (cands)
-                  (mapatoms
-                   (lambda (vv)
-                     (when (or (get vv 'variable-documentation)
-                               (and (boundp vv) (not (keywordp vv))))
-                       (push (symbol-name vv) cands))))
-                  cands)
-                :keymap counsel-describe-map
-                :preselect preselect
-                :history 'counsel-describe-symbol-history
-                :require-match t
-                :sort t))
-     (list (if (equal val "")
-               v
-             (intern val)))))
-  (unless (eq ivy--action 'counsel--find-symbol)
-    (describe-variable variable buffer frame)))
+(defun counsel-describe-variable ()
+  "Forward to `describe-variable'."
+  (interactive)
+  (let ((enable-recursive-minibuffers t))
+    (ivy-read
+     "Describe variable: "
+     (let (cands)
+       (mapatoms
+        (lambda (vv)
+          (when (or (get vv 'variable-documentation)
+                    (and (boundp vv) (not (keywordp vv))))
+            (push (symbol-name vv) cands))))
+       cands)
+     :keymap counsel-describe-map
+     :preselect (thing-at-point 'symbol)
+     :history 'counsel-describe-symbol-history
+     :require-match t
+     :sort t
+     :action (lambda ()
+               (describe-variable
+                (intern ivy--current))))))
 
-(defun counsel-describe-function (function)
-  "Forward to (`describe-function' FUNCTION) with ivy completion."
-  (interactive
-   (let ((fn (function-called-at-point))
-         (enable-recursive-minibuffers t)
-         (preselect (thing-at-point 'symbol))
-         val)
-     (setq ivy--action nil)
-     (setq val (ivy-read "Describe function: "
-                         (let (cands)
-                           (mapatoms
-                            (lambda (x)
-                              (when (fboundp x)
-                                (push (symbol-name x) cands))))
-                           cands)
-                         :keymap counsel-describe-map
-                         :preselect preselect
-                         :history 'counsel-describe-symbol-history
-                         :require-match t
-                         :sort t))
-     (list (if (equal val "")
-               fn (intern val)))))
-  (unless (eq ivy--action 'counsel--find-symbol)
-    (describe-function function)))
+(defun counsel-describe-function ()
+  "Forward to `describe-function'."
+  (interactive)
+  (let ((enable-recursive-minibuffers t))
+    (ivy-read "Describe function: "
+              (let (cands)
+                (mapatoms
+                 (lambda (x)
+                   (when (fboundp x)
+                     (push (symbol-name x) cands))))
+                cands)
+              :keymap counsel-describe-map
+              :preselect (thing-at-point 'symbol)
+              :history 'counsel-describe-symbol-history
+              :require-match t
+              :sort t
+              :action (lambda ()
+                        (describe-function
+                         (intern ivy--current))))))
 
 (defvar info-lookup-mode)
 (declare-function info-lookup->completions "info-look")
                                       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)