(or emacs irrelevant)

New on MELPA - avy

This package contains the library on which ace-window and ace-link now depend, as well as a multitude of navigation commands.

logo.png

Intro

Yes, they used to depend on ace-jump-mode, hence the ace in their names, but as I added features to my packages over time, it became harder to compose features because of ace-jump-mode inflexibility.

Don't get me wrong, ace-jump-mode is a fine standalone package, and if you're using it only for jumping to chars, there are few reasons for you to make the switch. However, if you're interested in the new and juicy features, such as:

  • jumping to word starts
  • jumping to sub-word starts
  • jumping to line beginnings or endings
  • copying and moving lines

with most of the features coming in -0, -1, or -2 flavor, or if you're interested in building an ace-jump-mode-based package, then you should consider avy.

The leading chars flavor

All of the commands provided are about jumping to visible characters, and possibly doing some stuff. Since usually there are a lot of these visible characters, it's advantageous to first narrow them somewhat. So each command can be divided into two phases: the narrowing phase and the decision phase.

There are 3 variations of the narrowing phase:

  • The -0 flavor, e.g. avy-goto-word-0 or avy-goto-line doesn't narrow at all. The advantage that there's minimum context switching (no narrowing phase, only decision phase). The disadvantage is that the number of candidates in the decision phase can be quite large.

  • The -1 flavor, e.g. avy-goto-word-1 or avy-goto-char narrows by the first character of the thing. The disadvantage is the context switch: first you call the command, then you switch context to scan and input the leading char, then you switch context to scan and input the decision chars. The advantage is less candidates in the decision phase.

  • The -2 flavor is my favorite avy-goto-char-2: it reads two consecutive chars, instead of just one. This doesn't impact the narrowing phase too much, since inputting two consecutive chars isn't much more than just one. But it greatly decreases the number of candidates in the decision phase. The small amount of candidates allows me to use this setting for the decision:

(setq avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))

That's only 9 decision chars, all of them on the home row.

The decision char overlay flavors

Once again, there are three, here are their corresponding defcustoms:

(defcustom avy-goto-char-style 'pre
  "Method of displaying the overlays for `avy-goto-char' and `avy-goto-char-2'."
  :type '(choice
          (const :tag "Pre" pre)
          (const :tag "At" at)
          (const :tag "Post" post)))

(defcustom avy-goto-word-style 'pre
  "Method of displaying the overlays for `avy-goto-word-0' and `avy-goto-word-0'."
  :type '(choice
          (const :tag "Pre" pre)
          (const :tag "At" at)
          (const :tag "Post" post)))

If you're used to ace-jump-mode, the corresponding style is at, which displays the overlay at the target position, one character at a time. I don't like this style most of the time, I prefer pre which is more similar to vim-easymotion: it will display the full char path at once, before the target position. This results in less feedback and more efficiency, in my opinion.

Outro

Give the new package a try, it's already been pretty active the last few days, with bugs being fixed and new features appearing, thanks to all who contributed.

If you want to see some screenshots, there are plenty at the repository page, and also in an earlier post.

Finally, the package in on MELPA, so it's convenient to install. The only hassle is to decide where to bind all these commands.