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
This commit is contained in:
Oleh Krehel 2015-10-21 12:38:14 +02:00
parent 528125e096
commit 513c42991c

28
avy.el
View File

@ -1132,15 +1132,18 @@ read string immediately instead of waiting for another char for
(window-list) (window-list)
(list (selected-window)))) (list (selected-window))))
(with-selected-window win (with-selected-window win
(save-excursion (dolist (pair (avy--find-visible-regions
(goto-char (window-start)) (window-start)
(setq regex (regexp-quote str)) (window-end (selected-window) t)))
(while (re-search-forward regex (window-end) t) (save-excursion
(unless (get-char-property (point) 'invisible) (goto-char (car pair))
(let ((ov (make-overlay (match-beginning 0) (match-end 0)))) (setq regex (regexp-quote str))
(push ov overlays) (while (re-search-forward regex (cdr pair) t)
(overlay-put ov 'window (selected-window)) (unless (get-char-property (point) 'invisible)
(overlay-put ov 'face 'avy-goto-char-timer-face))))))))) (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) str)
(dolist (ov overlays) (dolist (ov overlays)
(delete-overlay ov))))) (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. "Read one or many consecutive chars and jump to the first one.
The window scope is determined by `avy-all-windows' (ARG negates it)." The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P") (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-with avy-goto-char-timer
(avy--generic-jump (avy--generic-jump
(regexp-quote str) (regexp-quote str)