jasonwryan.com

Miscellaneous ephemera…

Using Notmuch with Mutt

Seeing as I have been focussing on my mail client, I thought I would round out the trifecta of Mutt posts1 with what I am assuming is the final piece of the puzzle: searching mutt's maildirs. For a small to average size mailbox, mutt's searching works fine, but as your mail volume grows this simple search doesn’t really scale. That’s where the rather modestly named Notmuch comes into play.

It can be run as a standalone mail client, but you can also use it with mutt to provide a ruthlessly efficient and fast search tool for your email. I had looked at it and Sup a couple of years ago, but was spurred to do something about it this week when Gunnar Lundström pinged me on twitter and suggested I check it out. So I did.

“Not much mail” is what Notmuch thinks about your email collection. Even if you receive 12000
messages per month or have on the order of millions of messages that you’ve been saving for decades.
Regardless, Notmuch will be able to quickly search all of it. It’s just plain not much mail.

There was previously a mutt-notmuch script for integrating the two, but the functionality was included upstream at the start of this year so it is quite straightforward to set it up. There is a package in the AUR but it is intended as the full mail client, complete with, shudder, emacs support amongst other things. I have stripped out the uneeded bindings and included the relevant perl libraries in a modified PKGBUILD if you just want the basic search with mutt.

Otherwise, you’ll need to step through it manually.

pacman -S perl perl-mailtools perl-mail-box perl-string-shellquote
cowerd notmuch perl-term-readline-gnu

As you will see from the PKGBUILD, you will need to copy the notmuch-mutt script into your $PATH: you’ll find it in contrib/notmuch-mutt/.

There is a simple interative setup, which you can complete before running the index the first time:

notmuch setup
notmuch new

The final step is to copy across the mutt macros included with the script:

cat src/notmuch-0.13/contrib/notmuch-mutt/notmuch-mutt.rc >> $HOME/.mutt/muttrc

Now, from within mutt, F8, F9 and F6 will respectively search, create the relevant threads from search results, and tag mails with notmuch.

As I use offlineimap to retrieve my mail, I simply added notmuch new to the script that runs as a cron job to synch my mail and notmuch reindexes all of my mail as soon as it arrives.

Updated 27/5/12

Two of the mutt macros that are shipped in contrib/notmuch-mutt/notmuch-mutt.rc do not work. I have written a patch to fix this and posted it to the ML.

Notes

  1. Using Mutt, LDAP and SSL and Mutt and HTML email

Creative Commons image by mjtmail on Flickr

Comments