Mutt mail indexing on steroids!

Update 31/03/2012: mutt-notmuch has been integrated upstream under the name notmuch-mutt.

I've been using external mail indexing with Mutt for quite a while now. Before now I haven't given Notmuch a try, as it seemed too much experimental at the time of my initial review of mail indexing tools.

As there is nothing better than a long oversea flight to perpetrate new hacks, I've now not only tested it, but also switched to Notmuch without looking back at maildir-utils for a split second.

Getting started with Notmuch is trivial:

  • Notmuch is notmuch in Debian (and maintained by upstream author, thanks!)
  • notmuch setup asks a few questions about the user and then prepare a template ~/.notmuch-config, which is good enough to start
  • notmuch new does a first run of indexing (which might take a while, depending on the size of your maildirs)

Some performance figures: (1) the size of the index is a bit larger than the size of the mails (on my laptop: 535 Mb of index vs 375 Mb of mails stored in 60 maildirs); (2) even if the underlying indexing engine is the same (Xapian) as maildir-utils, Notmuch is much faster. With my setup it is so fast that I've added it as a hook triggered by offlineimap at the end of each synchronization:

    zack@usha:~$ grep -B 1 hook .offlineimaprc
    [Account Upsilon]
    postsynchook = notmuch new

With the big round of new mail downloaded in the morning, it hardly takes more than a few seconds to update Notmuch index, while with other periodic downloads Notmuch almost invariably reports "... in almost no time" (i.e. less than 1 second).

Integrating Notmuch with Mutt

The basic integration I want between Mutt and a mail indexer is the ability of stating a search query interactively and then jump to a fresh Maildir containing search results only. Additionally, given that Notmuch has neat thread reconstruction abilities, I also want to be able to reconstruct on the fly the thread corresponding to the currently highlighted mail: it comes handy when a thread has been split across different maildirs, archived, or the like.

To that end, I've cooked up a little helper, called mutt-notmuch, that enables to trigger mail searches via a Mutt macro (F8 being my choice) and reconstruct threads via another (F9). Check the manpage for the 2-liner configuration snippet for your ~/.muttrc.

Arguably, some of the logics of mutt-notmuch could disappear by adding support for a --output=symlinks flag to Notmuch. A bug report requesting that is pending: too bad oversea flights are not as good for accessing the Internet as they are for perpetrating hacks!

Download


Update 10/04/2011: mutt-notmuch code is now available via Git. Resistence to propose your own patches is futile! The above link to mutt-notmuch has been changed to point to the live Git version.

Update 11/02/2012: Git repository has been moved to Gitorious; links updated accordingly