Open Luis-Henriquez-Perez opened 5 years ago
avy-jump
now has a :pred
keyword parameter, so we can write an advice that amends a passed predicate and filters out current point.
(defun avy-jump-advice (orig-func &rest args)
(let* ((between-inclusive (lambda (val low high) (and (<= low val) (<= val high))))
(current-point (point))
(oldpred (plist-get :pred args))
(pred (lambda ()
(and
(let ((candidate (point))) (or (< candidate current-point) (> candidate (+ 3 current-point)))) ; +3 should be enough: with avy-goto-word-1 it's +1, with avy-goto-char-2 it's +2
(or (null oldpred) (funcall oldpred))))))
(apply orig-func (append args (list :pred pred)))))
(advice-add 'avy-jump :around #'avy-jump-advice)
I noticed that in custom avy commands I made that it is possible for the candidates to include the current point I'm on.
Since that's the point I'm already at, there's no need to jump to it. I can't think of a situation in which this would be useful (though if I'm wrong and there is, please let me know).
To remedy this I added filter to all my avy commands:
It's not a big deal, but I was wondering: should
avy
exclude the current point by default?Maybe a custom variable:
avy-exclude-current-point
would be nice?