(or emacs irrelevant)

Rushing headlong

And you're rushing headlong out of control...

-- Brian May

I've finally wrapped a piece of config that I was using for a while in a package called headlong.

What does it do?

It provides a macro called headlong-with that modifies minibuffer completion for the forms within it, making it faster in some situations. For instance:

(headlong-with
 (completing-read "Jump to bookmark: "
                  bookmark-alist nil t))

or:

(headlong-with (read-extended-command))

But more importantly, it provides two commands that can use it efficiently: headlong-bookmark-jump and headlong-bookmark-jump-other. The second one is basically the same as the first one, except it opens the bookmark with pop-to-buffer, i.e. in other window.

How does this completion work?

It's nothing fancy, you will just exit the minibuffer automatically as soon as there is only one completion candidate left. So it saves you one keystroke, namely RET. How much is one keystroke worth? It depends.

If you arrange your bookmarks in a way that I do, with each one starting with a different letter, it saves you 33% of the total keystrokes. For example, suppose I have:

(global-set-key (kbd "M-p") 'bookmark-jump)
(global-set-key (kbd "M-o") 'headlong-bookmark-jump)

Then I can jump to my bookmarked directory named "s: sources" with two methods:

  • M-psRET
  • M-os

The second method looks like it's 33% shorter, but it feels like it's even more, since pressing RET is harder than it should be on most keyboards.

Why is this cool?

This is cool because you can implement your bookmarks as efficiently as you would with just wrapping stuff with a lambda and using global-set-key, except that you can view and edit the bindings with bookmark-bmenu-list, and quickly the update bookmark positions with bookmark-set.

Here's what I get when I call M-x bookmark-bmenu-list:

bookmarks

In the list above:

  • black bookmarks are files
  • blue bookmarks are directories
  • pink bookmarks are functions (you need bookmark+ for them)

The package should be available in MELPA soon.