mirror of
https://github.com/abo-abo/avy.git
synced 2025-12-04 12:45:43 +00:00
avy.el (avy--process-1): Extract
This commit is contained in:
parent
8606a8984b
commit
70e384aee5
47
avy.el
47
avy.el
@ -725,27 +725,18 @@ Set `avy-style' according to COMMMAND as well."
|
|||||||
(when (looking-at-p "\\b")
|
(when (looking-at-p "\\b")
|
||||||
(ispell-word)))))))
|
(ispell-word)))))))
|
||||||
|
|
||||||
(defun avy--process (candidates overlay-fn)
|
(defun avy--process-1 (candidates overlay-fn)
|
||||||
"Select one of CANDIDATES using `avy-read'.
|
(let ((len (length candidates)))
|
||||||
Use OVERLAY-FN to visualize the decision overlay."
|
(cond ((= len 0)
|
||||||
(unless (and (consp (car candidates))
|
nil)
|
||||||
(windowp (cdar candidates)))
|
((= len 1)
|
||||||
(setq candidates
|
(car candidates))
|
||||||
(mapcar (lambda (x) (cons x (selected-window)))
|
(t
|
||||||
candidates)))
|
|
||||||
(let ((len (length candidates))
|
|
||||||
res)
|
|
||||||
(if (= len 0)
|
|
||||||
(progn
|
|
||||||
(message "zero candidates")
|
|
||||||
t)
|
|
||||||
(if (= len 1)
|
|
||||||
(setq res (car candidates))
|
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(avy--make-backgrounds
|
(avy--make-backgrounds
|
||||||
(avy-window-list))
|
(avy-window-list))
|
||||||
(setq res (cond ((eq avy-style 'de-bruijn)
|
(cond ((eq avy-style 'de-bruijn)
|
||||||
(avy-read-de-bruijn
|
(avy-read-de-bruijn
|
||||||
candidates avy-keys))
|
candidates avy-keys))
|
||||||
((eq avy-style 'words)
|
((eq avy-style 'words)
|
||||||
@ -754,9 +745,23 @@ Use OVERLAY-FN to visualize the decision overlay."
|
|||||||
(t
|
(t
|
||||||
(avy-read (avy-tree candidates avy-keys)
|
(avy-read (avy-tree candidates avy-keys)
|
||||||
overlay-fn
|
overlay-fn
|
||||||
#'avy--remove-leading-chars)))))
|
#'avy--remove-leading-chars))))
|
||||||
(avy--done)))
|
(avy--done))))))
|
||||||
(cond ((eq res 'restart)
|
|
||||||
|
(defun avy--process (candidates overlay-fn)
|
||||||
|
"Select one of CANDIDATES using `avy-read'.
|
||||||
|
Use OVERLAY-FN to visualize the decision overlay."
|
||||||
|
(unless (and (consp (car candidates))
|
||||||
|
(windowp (cdar candidates)))
|
||||||
|
(setq candidates
|
||||||
|
(mapcar (lambda (x) (cons x (selected-window)))
|
||||||
|
candidates)))
|
||||||
|
(let ((res (avy--process-1 candidates overlay-fn)))
|
||||||
|
(cond
|
||||||
|
((null res)
|
||||||
|
(message "zero candidates")
|
||||||
|
t)
|
||||||
|
((eq res 'restart)
|
||||||
(avy--process candidates overlay-fn))
|
(avy--process candidates overlay-fn))
|
||||||
;; ignore exit from `avy-handler-function'
|
;; ignore exit from `avy-handler-function'
|
||||||
((eq res 'exit))
|
((eq res 'exit))
|
||||||
@ -774,7 +779,7 @@ Use OVERLAY-FN to visualize the decision overlay."
|
|||||||
(funcall (or avy-action 'avy-action-goto)
|
(funcall (or avy-action 'avy-action-goto)
|
||||||
(if (consp res)
|
(if (consp res)
|
||||||
(car res)
|
(car res)
|
||||||
res)))))))
|
res))))))
|
||||||
|
|
||||||
(defvar avy--overlays-back nil
|
(defvar avy--overlays-back nil
|
||||||
"Hold overlays for when `avy-background' is t.")
|
"Hold overlays for when `avy-background' is t.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user