Skip to content

Commit

Permalink
swiper.el (swiper--avy-goto): Handle quit
Browse files Browse the repository at this point in the history
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 abo-abo#2062
  • Loading branch information
basil-conto committed May 14, 2019
1 parent fb64ea3 commit cc92e1c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions swiper.el
Expand Up @@ -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")
Expand Down Expand Up @@ -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 ()
Expand Down

0 comments on commit cc92e1c

Please sign in to comment.