Composing Avy

A couple of years ago Karthik Chikmagalur published a long, dense post on how Avy can do anything. For some reason—I no longer remember why—I never added his post to my blog queue. Recently his comment to my post Emacs Elements on Avy reacquainted me with his post and I’m astounded that I didn’t write about such a rich and useful post.

I’ve written many times about how Avy is one of my most-used commands. It makes it almost trivially easy to move around in the text on the screen. Avy has several commands—more than appear in the documentation. One of Karthik’s two main points is that there are too many commands to remember or bind so you should settle on just one and use it for everything. There’s some merit to that idea. He uses avy-goto-char-timer, which can, indeed, perform most of the tasks of the other commands. I use it everyday but my most used Avy command is avy-goto-word-1, which I like because it considers only letters beginning words and thus reduces the number of targets. As a practical matter, I restrict myself to those two Avy commands.

His second main point is that Avy is much more general and useful than you thought. After you select a target, the default action is to jump to that location but other actions are possible. There are several alternative actions, which you can see by typing ? when the list of targets appears.

But wait. There’s more. You can also easily add your own actions as Karthik demonstrates. His post shows several such actions with the code to achieve them. He also has a link to a file with all the code if you want to steal some or all of them.

This is a really good post and worth your time to read even though it is long. And, as I said in my Emacs Elements on Avy post, if you aren’t using Avy, you’re working too hard.

This entry was posted in General and tagged . Bookmark the permalink.