[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 70e384a 073/110: avy.el (avy--process-1): Extract
From: |
Oleh Krehel |
Subject: |
[elpa] master 70e384a 073/110: avy.el (avy--process-1): Extract |
Date: |
Sat, 11 May 2019 10:15:47 -0400 (EDT) |
branch: master
commit 70e384aee57fecc9ac58bb99a7de192d16b28733
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
avy.el (avy--process-1): Extract
---
avy.el | 89 +++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 47 insertions(+), 42 deletions(-)
diff --git a/avy.el b/avy.el
index 8dd73e2..df4ad49 100644
--- a/avy.el
+++ b/avy.el
@@ -725,6 +725,29 @@ Set `avy-style' according to COMMMAND as well."
(when (looking-at-p "\\b")
(ispell-word)))))))
+(defun avy--process-1 (candidates overlay-fn)
+ (let ((len (length candidates)))
+ (cond ((= len 0)
+ nil)
+ ((= len 1)
+ (car candidates))
+ (t
+ (unwind-protect
+ (progn
+ (avy--make-backgrounds
+ (avy-window-list))
+ (cond ((eq avy-style 'de-bruijn)
+ (avy-read-de-bruijn
+ candidates avy-keys))
+ ((eq avy-style 'words)
+ (avy-read-words
+ candidates avy-words))
+ (t
+ (avy-read (avy-tree candidates avy-keys)
+ overlay-fn
+ #'avy--remove-leading-chars))))
+ (avy--done))))))
+
(defun avy--process (candidates overlay-fn)
"Select one of CANDIDATES using `avy-read'.
Use OVERLAY-FN to visualize the decision overlay."
@@ -733,48 +756,30 @@ Use OVERLAY-FN to visualize the decision overlay."
(setq candidates
(mapcar (lambda (x) (cons x (selected-window)))
candidates)))
- (let ((len (length candidates))
- res)
- (if (= len 0)
- (progn
- (message "zero candidates")
- t)
- (if (= len 1)
- (setq res (car candidates))
- (unwind-protect
- (progn
- (avy--make-backgrounds
- (avy-window-list))
- (setq res (cond ((eq avy-style 'de-bruijn)
- (avy-read-de-bruijn
- candidates avy-keys))
- ((eq avy-style 'words)
- (avy-read-words
- candidates avy-words))
- (t
- (avy-read (avy-tree candidates avy-keys)
- overlay-fn
- #'avy--remove-leading-chars)))))
- (avy--done)))
- (cond ((eq res 'restart)
- (avy--process candidates overlay-fn))
- ;; ignore exit from `avy-handler-function'
- ((eq res 'exit))
- (t
- (avy-push-mark)
- (when (and (consp res)
- (windowp (cdr res)))
- (let* ((window (cdr res))
- (frame (window-frame window)))
- (unless (equal frame (selected-frame))
- (select-frame-set-input-focus frame))
- (select-window window))
- (setq res (car res)))
-
- (funcall (or avy-action 'avy-action-goto)
- (if (consp res)
- (car res)
- res)))))))
+ (let ((res (avy--process-1 candidates overlay-fn)))
+ (cond
+ ((null res)
+ (message "zero candidates")
+ t)
+ ((eq res 'restart)
+ (avy--process candidates overlay-fn))
+ ;; ignore exit from `avy-handler-function'
+ ((eq res 'exit))
+ (t
+ (avy-push-mark)
+ (when (and (consp res)
+ (windowp (cdr res)))
+ (let* ((window (cdr res))
+ (frame (window-frame window)))
+ (unless (equal frame (selected-frame))
+ (select-frame-set-input-focus frame))
+ (select-window window))
+ (setq res (car res)))
+
+ (funcall (or avy-action 'avy-action-goto)
+ (if (consp res)
+ (car res)
+ res))))))
(defvar avy--overlays-back nil
"Hold overlays for when `avy-background' is t.")
- [elpa] master 909483e 090/110: avy.el (avy--process): Make `overlay-fn' arg optional, (continued)
- [elpa] master 909483e 090/110: avy.el (avy--process): Make `overlay-fn' arg optional, Oleh Krehel, 2019/05/11
- [elpa] master 24b5137 087/110: Ignore mistyping when no candidates available, Oleh Krehel, 2019/05/11
- [elpa] master c4e2d50 077/110: avy.el: avy-goto-char will now display shortest overlays for cands near point, Oleh Krehel, 2019/05/11
- [elpa] master 1de6233 076/110: Add avy-goto-end-of-line, Oleh Krehel, 2019/05/11
- [elpa] master c2e2a4a 083/110: avy.el (avy--read-candidates): Custom keys for deleting last read char, Oleh Krehel, 2019/05/11
- [elpa] master 4f1b8a1 086/110: avy.el: Fix compiler warnings, Oleh Krehel, 2019/05/11
- [elpa] master e7c0fc0 088/110: avy.el (avy-pre-action): New defvar, Oleh Krehel, 2019/05/11
- [elpa] master bcc0cb0 085/110: avy.el (avy-org-refile-as-child): Don't refile when avy aborted, Oleh Krehel, 2019/05/11
- [elpa] master 6331b7a 071/110: avy.el (avy--process): Fix avy-goto-line for empty buffer, Oleh Krehel, 2019/05/11
- [elpa] master fd7b929 078/110: Add option to display an indented goto line overlay, Oleh Krehel, 2019/05/11
- [elpa] master 70e384a 073/110: avy.el (avy--process-1): Extract,
Oleh Krehel <=
- [elpa] master cd8fb10 081/110: avy.el (avy--read-candidates): Quit on ESC, Oleh Krehel, 2019/05/11
- [elpa] master df4c4ac 084/110: Show number of matches so far in prompt, Oleh Krehel, 2019/05/11
- [elpa] master 93d4bd2 066/110: avy.el: Fix indentation, Oleh Krehel, 2019/05/11
- [elpa] master 157486a 079/110: avy.el: Fix compiler warning, Oleh Krehel, 2019/05/11
- [elpa] master abe150c 082/110: Introduce single candidate jump customization, Oleh Krehel, 2019/05/11
- [elpa] master a29558d 080/110: Add C-h/DEL/RET info to README for avy-goto-char-timer, Oleh Krehel, 2019/05/11
- [elpa] master 7c40f5e 075/110: avy.el (avy--process): Fix the candidates list being modified when restarting, Oleh Krehel, 2019/05/11
- [elpa] master 58e8636 070/110: avy.el (avy-action-zap-to-char): More convenient use-cases, Oleh Krehel, 2019/05/11
- [elpa] master 34d3531 067/110: avy.el (avy-action-goto): Remove lag, Oleh Krehel, 2019/05/11
- [elpa] master 6459f7f 065/110: README.md: Mention avy-resume, Oleh Krehel, 2019/05/11