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

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

[elpa] master 88b3548 020/399: swiper.el (swiper--avy-goto): Extract


From: Oleh Krehel
Subject: [elpa] master 88b3548 020/399: swiper.el (swiper--avy-goto): Extract
Date: Sat, 20 Jul 2019 14:56:40 -0400 (EDT)

branch: master
commit 88b35486c5751e48e0b36ca0dbce91bf56a378d6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper--avy-goto): Extract
---
 swiper.el | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/swiper.el b/swiper.el
index 2e3a4e9..0fd7d06 100644
--- a/swiper.el
+++ b/swiper.el
@@ -208,6 +208,22 @@
            (avy-push-mark))
       (avy--done))))
 
+(defun swiper--avy-goto (candidate)
+  (if (window-minibuffer-p (cdr candidate))
+      (let ((cand-text (save-excursion
+                         (goto-char (car candidate))
+                         (buffer-substring-no-properties
+                          (line-beginning-position)
+                          (line-end-position)))))
+        (ivy-set-index (cl-position-if
+                        (lambda (x) (cl-search x cand-text))
+                        ivy--old-cands))
+        (ivy--exhibit)
+        (ivy-done)
+        (ivy-call))
+    (ivy-quit-and-run
+      (avy-action-goto (avy-candidate-beg candidate)))))
+
 ;;;###autoload
 (defun swiper-avy ()
   "Jump to one of the current swiper candidates."
@@ -215,21 +231,7 @@
   (unless (require 'avy nil 'noerror)
     (error "Package avy isn't installed"))
   (unless (string= ivy-text "")
-    (let ((candidate (swiper--avy-candidate)))
-      (if (window-minibuffer-p (cdr candidate))
-          (let ((cand-text (save-excursion
-                             (goto-char (car candidate))
-                             (buffer-substring-no-properties
-                              (line-beginning-position)
-                              (line-end-position)))))
-            (ivy-set-index (cl-position-if
-                            (lambda (x) (cl-search x cand-text))
-                            ivy--old-cands))
-            (ivy--exhibit)
-            (ivy-done)
-            (ivy-call))
-        (ivy-quit-and-run
-          (avy-action-goto (avy-candidate-beg candidate)))))))
+    (swiper--avy-goto (swiper--avy-candidate))))
 
 (declare-function mc/create-fake-cursor-at-point "ext:multiple-cursors-core")
 (declare-function multiple-cursors-mode "ext:multiple-cursors-core")



reply via email to

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