mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-13 13:33:03 +00:00
fix(avy-next/prev): Allow avy-next/prev to handle non-cons candidates.
This commit fixes the `avy-last-candidates-cycle` / `avy-next` / `avy-pref` defun's so that they can handle candidates with non-cons car elements (as are set up by `avy-goto-line`.) Without this fix, `avy-next` / `avy-prev` throw errors if the last `avy` commands was `avy-goto-line`.
This commit is contained in:
parent
d9634efe26
commit
be612110cb
10
avy.el
10
avy.el
@ -838,11 +838,11 @@ Set `avy-style' according to COMMAND as well."
|
|||||||
avy-last-candidates))
|
avy-last-candidates))
|
||||||
(min-dist
|
(min-dist
|
||||||
(apply #'min
|
(apply #'min
|
||||||
(mapcar (lambda (x) (abs (- (caar x) (point)))) avy-last-candidates)))
|
(mapcar (lambda (x) (abs (- (if (listp (car x)) (caar x) (car x)) (point)))) avy-last-candidates)))
|
||||||
(pos
|
(pos
|
||||||
(cl-position-if
|
(cl-position-if
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(= (- (caar x) (point)) min-dist))
|
(= (- (if (listp (car x)) (caar x) (car x)) (point)) min-dist))
|
||||||
avy-last-candidates)))
|
avy-last-candidates)))
|
||||||
(funcall advancer pos avy-last-candidates)))
|
(funcall advancer pos avy-last-candidates)))
|
||||||
|
|
||||||
@ -852,7 +852,8 @@ Set `avy-style' according to COMMAND as well."
|
|||||||
(avy--last-candidates-cycle
|
(avy--last-candidates-cycle
|
||||||
(lambda (pos lst)
|
(lambda (pos lst)
|
||||||
(when (> pos 0)
|
(when (> pos 0)
|
||||||
(goto-char (caar (nth (1- pos) lst)))))))
|
(let ((candidate (nth (1- pos) lst)))
|
||||||
|
(goto-char (if (listp (car candidate)) (caar candidate) (car candidate))))))))
|
||||||
|
|
||||||
(defun avy-next ()
|
(defun avy-next ()
|
||||||
"Go to the next candidate of the last `avy-read'."
|
"Go to the next candidate of the last `avy-read'."
|
||||||
@ -860,7 +861,8 @@ Set `avy-style' according to COMMAND as well."
|
|||||||
(avy--last-candidates-cycle
|
(avy--last-candidates-cycle
|
||||||
(lambda (pos lst)
|
(lambda (pos lst)
|
||||||
(when (< pos (1- (length lst)))
|
(when (< pos (1- (length lst)))
|
||||||
(goto-char (caar (nth (1+ pos) lst)))))))
|
(let ((candidate (nth (1+ pos) lst)))
|
||||||
|
(goto-char (if (listp (car candidate)) (caar candidate) (car candidate))))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun avy-process (candidates &optional overlay-fn cleanup-fn)
|
(defun avy-process (candidates &optional overlay-fn cleanup-fn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user