abo-abo / avy

Jump to things in Emacs tree-style
1.71k stars 109 forks source link

[Feature request] Go to the end of a candidate instead of the beginning #316

Closed irigone closed 3 years ago

irigone commented 3 years ago

I want to go to the end of the candidate instead of its beginning. In my opinion, it's more intuitive, and most of people are already used to that, because they already used isearch. There should be a variable that changes that behaviour. I find myself C-f'ing several times after using avy just because of that. For example, if I want to change align to align* in LaTeX, I'd instinctively use avy-goto-char-timer and type "align", then go to that candidate with the tree, because I want to append an asterisk. Now, after I do that, I'll have to type M-f to go to the end of the word. In this example, it's more intuitive to go to the end of the candidate, because for a human reading the word align is much, much more eaosier than n} It goes even worse when I want to edit a word inside it. If I type "doucmentation" and want to fix my typo, I'd usually type "douc", then edit. However, instead of that, I have to type C-f C-f C-d C-d to change that. In this situation, it's easier to go to the end of candidate, too, because with the default behavior you have to skip the "douc" in your mind and then read the "mentation". This is obviously less intuitive. This would also add #224 functionality, btw. There are indeed situations where going to the beginning of the candidate is easier (like when you need to change "there" to "There", but in my opinion, this barely happens. This is why there should be a variable that controls that, so that the user could make a simple function with a let that goes to the beginning of that candidate.

a13 commented 3 years ago

It goes even worse when I want to edit a word inside it

why don't you use avy-goto-char-timer for that? the algorithm could be

M-x avy-goto-char-timer, c, "jump letters", C-t (to transpose)

a13 commented 3 years ago

avy-goto-char-timer and type "align"

avy-goto-char-timer doesn't support multiple letters, are you sure you're not using avy-goto-word or something like that?

in your case I'd just use M-x avy-goto-char-timer, SPC, "jump", *

irigone commented 3 years ago

avy-goto-char-timer doesn't support multiple letters, are you sure you're not using avy-goto-word or something like that?

The documentation string says that it does?

avy-goto-char-timer is an autoloaded interactive compiled Lisp
function in ‘avy.el’.

It is bound to C-'.

(avy-goto-char-timer &optional ARG)

Read one or many consecutive chars and jump to the first one.
The window scope is determined by ‘avy-all-windows’ (ARG negates it).

in your case I'd just use M-x avy-goto-char-timer, SPC, "jump", *

I don't understand your solution. This is how I see your comment:

  1. M-x avy-goto-char-timer
  2. Type "align"
  3. Wait for avy-goto-char-timer to stop
  4. IDK.

I have problems with English...

irigone commented 3 years ago

Or maybe

  1. M-x avy-goto-char-timer
  2. Type SPC
  3. Type "align"
  4. Jump (whatever this means)
  5. Type the asterisk This won't work because SPC is registered as a space character, and thus the {align} will not be considered a candidate at all.
irigone commented 3 years ago

I can wrap around avy-goto-char-2 because it always uses 2 characters so... the issue is solved for me, but I really wish I could use goto-char-timer...

irigone commented 3 years ago

This solves the issue for me. I read the source code. Yay, I'm (kinda) learning Lisp!

(defun avy-goto-char-timer-end (&optional arg)
  "Read one or many consecutive chars and jump to the last one.
The window scope is determined by `avy-all-windows' (ARG negates it)."
  (interactive "P")
  (avy-goto-char-timer arg)
  (forward-char (length avy-text)))

Edit 2020-12-17 04:05 AM GMT+6: length as forward-char argument instead of dotimes.