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

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

[elpa] master cc92e1c 238/399: swiper.el (swiper--avy-goto): Handle quit


From: Oleh Krehel
Subject: [elpa] master cc92e1c 238/399: swiper.el (swiper--avy-goto): Handle quit
Date: Sat, 20 Jul 2019 14:57:31 -0400 (EDT)

branch: master
commit cc92e1c267e834877bd30ac724894ef308d10f38
Author: Basil L. Contovounesios <address@hidden>
Commit: Basil L. Contovounesios <address@hidden>

    swiper.el (swiper--avy-goto): Handle quit
    
    avy-read et al. can return values that do not correspond to
    particular candidates, such as the symbol 'exit'.  This is handled
    in avy-process, which sadly doesn't seem reusable in this case.
    Ideally, swiper-avy could reuse a higher-level avy API.
    
    Fixes #2062
---
 swiper.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/swiper.el b/swiper.el
index 95bd1d0..204677f 100644
--- a/swiper.el
+++ b/swiper.el
@@ -206,12 +206,9 @@
                     (perform-replace from to t t nil)))
              (set-window-configuration wnd-conf))))))))
 
-(defvar avy-background)
 (defvar avy-all-windows)
 (defvar avy-style)
 (defvar avy-keys)
-(declare-function avy--regex-candidates "ext:avy")
-(declare-function avy--process "ext:avy")
 (declare-function avy--overlay-post "ext:avy")
 (declare-function avy-action-goto "ext:avy")
 (declare-function avy-candidate-beg "ext:avy")
@@ -280,20 +277,23 @@
       (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)))))
+  (cond ((let ((win (cdr-safe candidate)))
+           (and win (window-minibuffer-p win)))
+         (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)))
+        ((or (consp candidate)
+             (number-or-marker-p candidate))
+         (ivy-quit-and-run
+           (avy-action-goto (avy-candidate-beg candidate))))))
 
 ;;;###autoload
 (defun swiper-avy ()



reply via email to

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