From 513c42991c658226aa598e63e0d53837e6df642f Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 21 Oct 2015 12:38:14 +0200 Subject: [PATCH] Make avy-goto-char-timer faster for org-mode * avy.el (avy--read-string-timer): Use `avy--find-visible-regions'. (avy-goto-char-timer): Make ARG work properly to negate `avy-all-windows'. Re #100 --- avy.el | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/avy.el b/avy.el index 1291834..8296def 100644 --- a/avy.el +++ b/avy.el @@ -1132,15 +1132,18 @@ read string immediately instead of waiting for another char for (window-list) (list (selected-window)))) (with-selected-window win - (save-excursion - (goto-char (window-start)) - (setq regex (regexp-quote str)) - (while (re-search-forward regex (window-end) t) - (unless (get-char-property (point) 'invisible) - (let ((ov (make-overlay (match-beginning 0) (match-end 0)))) - (push ov overlays) - (overlay-put ov 'window (selected-window)) - (overlay-put ov 'face 'avy-goto-char-timer-face))))))))) + (dolist (pair (avy--find-visible-regions + (window-start) + (window-end (selected-window) t))) + (save-excursion + (goto-char (car pair)) + (setq regex (regexp-quote str)) + (while (re-search-forward regex (cdr pair) t) + (unless (get-char-property (point) 'invisible) + (let ((ov (make-overlay (match-beginning 0) (match-end 0)))) + (push ov overlays) + (overlay-put ov 'window (selected-window)) + (overlay-put ov 'face 'avy-goto-char-timer-face)))))))))) str) (dolist (ov overlays) (delete-overlay ov))))) @@ -1150,7 +1153,12 @@ read string immediately instead of waiting for another char for "Read one or many consecutive chars and jump to the first one. The window scope is determined by `avy-all-windows' (ARG negates it)." (interactive "P") - (let ((str (avy--read-string-timer))) + (let ((str + (let ((avy-all-windows + (if arg + (not avy-all-windows) + avy-all-windows))) + (avy--read-string-timer)))) (avy-with avy-goto-char-timer (avy--generic-jump (regexp-quote str)