abo-abo / avy

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

keep ivy-avy candidates active while scrolling #276

Closed Luis-Henriquez-Perez closed 5 years ago

Luis-Henriquez-Perez commented 5 years ago

I really love the ivy-avy feature. Using it, however, I've thought of ways to make selecting ivy candidates even more efficient.

I propose two things: 1- add an option to execute ivy-avy by default when selecting ivy candidates (or perhaps this could be a list of the ivy commands you'd like ivy-avy to be active in by default). 2- keep ivy candidates active while scrolling

As it is currently after activating ivy-avy with C-' you can select candidates by pressing the avy keys. If you try to scroll down or move down you get an error No such candidate. I think it'd be excellent if you could still scroll down while keeping the avy candidates on the screen. The avy candidates displayed could even stay the same as you scroll down (in other words, they'd only point the currently displayed ivy candidates). This way, you'd never have to scroll down by individual ivy candidates; all you'd do is go down or up by page and press a single key to select a candidate.

Thinking more about it it would be nice if the candidates remained active even while typing in and narrowing down the search results. Of course this is a bit harder because you'd either have to use avy-keys that would be non-overlapping (like numbers) or I suppose avy-keys could be dynamically changed as you type so none is overlapping.

I'm willing to write code to get this feature.

abo-abo commented 5 years ago

I'm willing to write code to get this feature.

Thanks. Scrolling is now possible with C-v and M-v. Feel free to have a look at the referenced commit and PR with improvements.

Luis-Henriquez-Perez commented 5 years ago

Thanks so much for this change. This will make scrolling up or down by one candidate obsolete for me. :)

One question, how do I call avy-ivy automatically (without even pressing C-;) after ivy-read? Since I want it to be called every time I select candidates, I don't want to press C-; all the time. I don't see an option in ivy-read for this case, would I have to modify it?

abo-abo commented 5 years ago

Yes, you have to modify it. Doesn't look easy, unfortunately.

Luis-Henriquez-Perez commented 5 years ago

Haha, you're sure right about that.

This almost does it, but not quite:

(advice-add #'ivy--minibuffer-setup :after #'ivy-avy)

I'll see what I can do.

abo-abo commented 5 years ago

The problem is not specific to ivy. It's how to run a command after read-from-minibuffer. minibuffer-with-setup-hook is not exactly it.

It ivy-test.el I use execute-kbd-macro to run commands after entering the minibuffer. Might be useful for you.