abo-abo / avy

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

Feature request avy-action-zap-up-to-char and avy-action-zap-to-char #234

Closed eflanigan00 closed 6 years ago

eflanigan00 commented 6 years ago

Similar to zap-to-char but with the ability to trigger off avy action

zap-up-to-char doesn't include the entered char zap-to-char does include the entered char

Binding is flexible but these might work: avy-action-zap-up-to-char bind to 'z' avy-action-zap-to-char bind to 'Z'

abo-abo commented 6 years ago

Thanks, let me know what you think about the added one.

If there's nice a use case for the other one, I'll add it later, but I'd like to keep things simple.

eflanigan00 commented 6 years ago

The added one works, thanks for adding it. I really think we need both.

When I'm deleting backward I use zap-to-char (includes the character I'm deleting).

When I'm deleting forward I use zap-up-to-char (doesn't include the character)

Examples below:

  1. My cursor is at C and I use zap-up-to-char to delete up to the word (including the whitespace) but not including the word. In the example I'm deleting up to description (but not including)

    This is my sentence and Cthere is some description

Results in

 This is my sentence and description
  1. my cursor is at C then I use zap-to-char to delete This (including)

    This is my sentence and Cthere is some description

Results in

 there is some description

If I had to pick only one I would prefer to have zap-up-to-char because of how I navigate files and edit. But that will vary depending on the user.

eflanigan00 commented 6 years ago

Another use case for zap-up-to-char is when using avy-goto-line. The current implementation deletes the first character of the line the user specifies. I would imagine that zap-up-to-char wouldn't have this problem.

eflanigan00 commented 6 years ago

@abo-abo can you please add the other one also based on my comments above?

abo-abo commented 6 years ago

Will do. Is there a way to merge the two commands into one?

eflanigan00 commented 6 years ago

I'm not sure. It is really 5 or 6 lines or code and to me having both makes sense but I could be overlooking something.

abo-abo commented 6 years ago

overlooking something

We should try not to overlook the opportunity to simplify things. If one new command does the job of two old commands, it's a win.

For instance, you say:

So why not unify them into a single command-3 that uses the command-1 logic if the target is after the point and command-2 logic otherwise.

eflanigan00 commented 6 years ago

I really like your design approach to this @abo-abo. You make great points. And I love the idea of a unified command. It simplifies the user interface and makes us all more efficient editors.

I would really like this new command to work well with avy-goto-line because I think that is a really powerful utility when paired with the avy actions. It seems your proposed command-3 will work for the goto-line case also.

eflanigan00 commented 6 years ago

@abo-abo would you be able to make this update easily?

abo-abo commented 6 years ago

Hi, sorry for the late response, I've had other things piling up. I'm coming back from vacation next week, I'll try to figure out this feature soon.

eflanigan00 commented 6 years ago

No problem take your time. I hope you had a great vacation!

eflanigan00 commented 6 years ago

@abo-abo any chance you can add this feature?

abo-abo commented 6 years ago

Sorry delaying. Yes, I'll add it eventually. But if I don't manage before this Friday, you'll have to wait until June; I have one more vacation coming up:)

abo-abo commented 6 years ago

OK, I've made a small modification that results in both of your use cases working. See also the commit message.

If you have more use cases that don't work currently, please open a new issue.

eflanigan00 commented 6 years ago

This is amazing, thank you so much. Have a great second vacation, you deserve it!!