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

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

[elpa] externals/ivy-posframe 44af982 3/7: ivy-posframe-swiper-avy: Rewr


From: Feng Shu
Subject: [elpa] externals/ivy-posframe 44af982 3/7: ivy-posframe-swiper-avy: Rewrite.
Date: Sat, 3 Oct 2020 08:23:47 -0400 (EDT)

branch: externals/ivy-posframe
commit 44af9828bf764f5910a2a6d959fff2ee927077a2
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    ivy-posframe-swiper-avy: Rewrite.
    
        * ivy-posframe.el (ivy-posframe--swiper--avy-goto): New function.
        (ivy-posframe-swiper-avy): Rewrite.
---
 ivy-posframe.el | 52 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/ivy-posframe.el b/ivy-posframe.el
index 4069d36..c65d5ef 100644
--- a/ivy-posframe.el
+++ b/ivy-posframe.el
@@ -442,8 +442,34 @@ This variable is useful for `ivy-posframe-read-action' .")
 
 (declare-function avy-action-goto "avy")
 (declare-function avy-candidate-beg "avy")
+
+(defun ivy-posframe--swiper--avy-goto (candidate)
+  (cond ((eq (cdr-safe candidate)
+             (ivy-posframe--window))
+         (let ((cand-text (with-current-buffer ivy-posframe-buffer
+                            (save-excursion
+                              (goto-char (car candidate))
+                              (buffer-substring
+                               (line-beginning-position)
+                               (line-end-position))))))
+           (ivy-set-index
+            ;; cand-text may include "> ", using a hack way
+            ;; to deal with it.
+            (or (cl-some (lambda (n)
+                           (cl-position (substring cand-text n)
+                                        ivy--old-cands :test #'string=))
+                         '(0 1 2 3 4))
+                0))
+           (ivy--exhibit)
+           (ivy-done)
+           (ivy-call)))
+        ((or (consp candidate)
+             (number-or-marker-p candidate))
+         (ivy-quit-and-run
+           (avy-action-goto (avy-candidate-beg candidate))))))
+
 (defun ivy-posframe-swiper-avy ()
-  "Jump to one of the current swiper candidates."
+  "ivy-posframe's `swiper-avy'."
   (interactive)
   (if (not (string-match-p "^ivy-posframe-display"
                            (symbol-name ivy--display-function)))
@@ -464,28 +490,8 @@ This variable is useful for `ivy-posframe-read-action' .")
        (let ((swiper-min-highlight 1))
          (swiper--update-input-ivy))))
     (unless (string= ivy-text "")
-      (let ((candidate (ivy-posframe--swiper-avy-candidate)))
-        (cond ((eq (cdr candidate) (ivy-posframe--window))
-               (let ((cand-text (with-current-buffer ivy-posframe-buffer
-                                  (save-excursion
-                                    (goto-char (car candidate))
-                                    (buffer-substring
-                                     (line-beginning-position)
-                                     (line-end-position))))))
-                 (ivy-set-index
-                  ;; cand-text may include "> ", using a hack way
-                  ;; to deal with it.
-                  (or (cl-some (lambda (n)
-                                 (cl-position (substring cand-text n) 
ivy--old-cands :test #'string=))
-                               '(0 1 2 3 4))
-                      0))
-                 (ivy--exhibit)
-                 (ivy-done)
-                 (ivy-call)))
-              ((or (consp candidate)
-                   (number-or-marker-p candidate))
-               (ivy-quit-and-run
-                 (avy-action-goto (avy-candidate-beg candidate)))))))))
+      (ivy-posframe--swiper--avy-goto
+       (ivy-posframe--swiper-avy-candidate)))))
 
 ;;; Variables
 



reply via email to

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