branch: master commit 51446e57a420983537b83d255a6cd29f9ba57828 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
swiper.el (swiper--avy-candidates): Extract --- swiper.el | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/swiper.el b/swiper.el index 0fd7d06..66ad50e 100644 --- a/swiper.el +++ b/swiper.el @@ -158,8 +158,8 @@ (declare-function avy-push-mark "ext:avy") (declare-function avy--remove-leading-chars "ext:avy") -(defun swiper--avy-candidate () - (let* ((avy-all-windows nil) +(defun swiper--avy-candidates () + (let* ( ;; We'll have overlapping overlays, so we sort all the ;; overlays in the visible region by their start, and then ;; throw out non-Swiper overlays or overlapping Swiper @@ -177,24 +177,28 @@ swiper-faces)) (setq min-overlay-start (overlay-start ov)))) visible-overlays)) - (offset (if (eq (ivy-state-caller ivy-last) 'swiper) 1 0)) - (candidates (nconc - (mapcar (lambda (ov) - (cons (overlay-start ov) - (overlay-get ov 'window))) - overlays-for-avy) - (save-excursion - (save-restriction - (narrow-to-region (window-start) (window-end)) - (goto-char (point-min)) - (forward-line) - (let ((win (selected-window)) - cands) - (while (not (eobp)) - (push (cons (+ (point) offset) win) - cands) - (forward-line)) - cands)))))) + (offset (if (eq (ivy-state-caller ivy-last) 'swiper) 1 0))) + (nconc + (mapcar (lambda (ov) + (cons (overlay-start ov) + (overlay-get ov 'window))) + overlays-for-avy) + (save-excursion + (save-restriction + (narrow-to-region (window-start) (window-end)) + (goto-char (point-min)) + (forward-line) + (let ((win (selected-window)) + cands) + (while (not (eobp)) + (push (cons (+ (point) offset) win) + cands) + (forward-line)) + cands)))))) + +(defun swiper--avy-candidate () + (let ((candidates (swiper--avy-candidates)) + (avy-all-windows nil)) (unwind-protect (prog2 (avy--make-backgrounds