abo-abo / avy

Jump to things in Emacs tree-style
1.72k stars 110 forks source link

[Feature request] Sort overlay keys by distance to the point #232

Closed MaskRay closed 6 years ago

MaskRay commented 6 years ago

This may be better explained with an avy-goto-line example:

;; l
;; k
;; j
;; h
;; [point]
;; a
;; s
;; d
;; f
;; g

asdfghjkl are taken from avy-keys. For the first character of overlay keys, avy-keys is split into two halves and one half is for positions after the point and the other is for positions before the point. The second, third, ... characters can be used freely.

In this way, users can form the muscular memory that: a is for the 1st occurrence forward, s is for the 2nd forward, ... h is for the 1st backward, j for the 2nd backward, ...

avy-goto-word-1 example:

// ......l..........k
// ....j...h [point]  a... s.... 
// d..... f......g......

This probably requires the function (defun avy--regex-candidates (regex &optional beg end pred group) returning two lists for both directions. When avy-all-windows is on, non-selected windows can use keys freely after keys are allocated to the selected window.

abo-abo commented 6 years ago

Fixed in #242. Please test.