avy.el (avy--process): Make `overlay-fn' arg optional

This commit is contained in:
Oleh Krehel 2019-01-15 15:25:30 +01:00
parent 16482e0012
commit 909483e104

31
avy.el
View File

@ -787,9 +787,10 @@ Set `avy-style' according to COMMMAND as well."
#'avy--remove-leading-chars)))) #'avy--remove-leading-chars))))
(avy--done)))))) (avy--done))))))
(defun avy--process (candidates overlay-fn) (defun avy--process (candidates &optional overlay-fn)
"Select one of CANDIDATES using `avy-read'. "Select one of CANDIDATES using `avy-read'.
Use OVERLAY-FN to visualize the decision overlay." Use OVERLAY-FN to visualize the decision overlay."
(setq overlay-fn (or overlay-fn (avy--style-fn avy-style)))
(unless (and (consp (car candidates)) (unless (and (consp (car candidates))
(windowp (cdar candidates))) (windowp (cdar candidates)))
(setq candidates (setq candidates
@ -1155,6 +1156,7 @@ exist."
(post #'avy--overlay-post) (post #'avy--overlay-post)
(de-bruijn #'avy--overlay-at-full) (de-bruijn #'avy--overlay-at-full)
(words #'avy--overlay-at-full) (words #'avy--overlay-at-full)
(ignore #'ignore)
(t (error "Unexpected style %S" style)))) (t (error "Unexpected style %S" style))))
(defun avy--generic-jump (regex window-flip &optional beg end) (defun avy--generic-jump (regex window-flip &optional beg end)
@ -1168,8 +1170,7 @@ BEG and END narrow the scope where candidates are searched."
(not avy-all-windows) (not avy-all-windows)
avy-all-windows))) avy-all-windows)))
(avy--process (avy--process
(avy--regex-candidates regex beg end) (avy--regex-candidates regex beg end))))
(avy--style-fn style))))
;;* Commands ;;* Commands
;;;###autoload ;;;###autoload
@ -1255,8 +1256,7 @@ When ARG is non-nil, do the opposite of `avy-all-windows'."
(avy--process (avy--process
(avy--regex-candidates (if isearch-regexp (avy--regex-candidates (if isearch-regexp
isearch-string isearch-string
(regexp-quote isearch-string))) (regexp-quote isearch-string))))
(avy--style-fn avy-style))
(isearch-done)))) (isearch-done))))
;;;###autoload ;;;###autoload
@ -1413,7 +1413,7 @@ BEG and END narrow the scope where candidates are searched."
(not (get-char-property (point) 'invisible)) (not (get-char-property (point) 'invisible))
(push (cons (point) (selected-window)) window-cands))) (push (cons (point) (selected-window)) window-cands)))
(setq candidates (nconc candidates window-cands)))))) (setq candidates (nconc candidates window-cands))))))
(avy--process candidates (avy--style-fn avy-style))))) (avy--process candidates))))
;;;###autoload ;;;###autoload
(defun avy-goto-subword-1 (char &optional arg) (defun avy-goto-subword-1 (char &optional arg)
@ -1566,13 +1566,14 @@ The window scope is determined by `avy-all-windows'.
When ARG is non-nil, do the opposite of `avy-all-windows'. When ARG is non-nil, do the opposite of `avy-all-windows'.
BEG and END narrow the scope where candidates are searched. BEG and END narrow the scope where candidates are searched.
When BOTTOM-UP is non-nil, display avy candidates from top to bottom" When BOTTOM-UP is non-nil, display avy candidates from top to bottom"
(let ((avy-action #'identity)) (let ((avy-action #'identity)
(avy--process (avy-style (if avy-linum-mode
(avy--line-cands arg beg end bottom-up) (progn
(if avy-linum-mode (message "Goto line:")
(progn (message "Goto line:")
'ignore) 'ignore)
(avy--style-fn avy-style))))) avy-style)))
(avy--process
(avy--line-cands arg beg end bottom-up))))
;;;###autoload ;;;###autoload
(defun avy-goto-line (&optional arg) (defun avy-goto-line (&optional arg)
@ -1978,8 +1979,7 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
avy-all-windows))) avy-all-windows)))
(avy-with avy-goto-char-timer (avy-with avy-goto-char-timer
(avy--process (avy--process
(avy--read-candidates) (avy--read-candidates)))))
(avy--style-fn avy-style)))))
(defun avy-push-mark () (defun avy-push-mark ()
"Store the current point and window." "Store the current point and window."
@ -2047,8 +2047,7 @@ The window scope is determined by `avy-all-windows' (ARG negates it)."
(avy--process (avy--process
(avy--read-candidates (avy--read-candidates
(lambda (input) (lambda (input)
(format "^\\*+ .*\\(%s\\)" input))) (format "^\\*+ .*\\(%s\\)" input))))
(avy--style-fn avy-style))
(org-back-to-heading)))) (org-back-to-heading))))
(provide 'avy) (provide 'avy)