Mutt mail indexing on steroids!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:
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:
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 MuttThe 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 Arguably, some of the logics of mutt-notmuch could disappear by
adding support for a 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 |

Notmuch seems interesting project. I my self tried different indexers couple of years a go, but finally found that best for my mail work flow was to just view all emails at once in Mutt. I did couple of neat limit key bindings and added colors to different mailing list messages and now my Mutt mail view has all messages quickly accessible.
Mutt is really fast with cache options enabled. For example my mutt status bar states: [Msgs:47453 New:53 531M] and the mailbox loads in 1 or 2 seconds.
Thanks for this very nice recipe.
Took me a bit of twiddeling to find out that the "libmail-box-perl" package is needed and to use the newer version of "notmuch" from unstable.
Now it just works *g*
Kudos
In the browser screen, change-folder-readonly doesn't work. You can use the following snippet instead:
Cheers
Hi Zack,
I think your script needs to live somewhere!
I thought perhaps "moreutils", but it might not fit there; there is also the "bikeshed" package in Ubuntu (hmm, not in Debian yet though, something to put on my maybe-ITP list)
If you use mutt-patched the F9 macro works, but if you use regular mutt and you have ignore message-id in your conf file, then you need to modify your lines as follows
othwise the script is fed with an incomplete header and cannot rebuild the thread.
Cheers
I guess the right package would be notmuch, since moreutils is more general purpose.
A completely new package for just one 100 lines scripts seems a bit overkilling, but is doable too.
Does anybody know how I could make mark email in that 'virtual mailbox as deleted or read?
I've tried replacing change-folder-readonly to change-folder, but that didn't help. That feature would make this setup perfect!
The associated perl script was very helpful, now I'm cruising along with notmuch + mutt + offlineimap. For you Fedora (14+) users out there, the following perl dependencies were needed for notmuch-mutt: "perl-Email-Sender perl-MailTools"
These will pull in the following perl packages and spamassasin: http://pastebin.com/nkfB5bRQ
Hi,
This is a great page! Integrating mutt with notmuch (and offlineimap) is fantastic. After doing this, one thing that I found I wanted was a way to tag and untag emails based on a selection made in mutt, i.e. tagging (in the notmuch sense) emails that have been tagged (in the mutt sense).
I can't write anything in perl so I can't contribute directly to your work, but was able to hack a small shell script together that does what I need. It is not pretty, but I thought I'd share it here. It looks like getting user input into mutt is not so easy, but using vi in this way seems to work.
# mutt-notmuch-tag.sh# Simple and crude script to tag multiple messagess in mutt using notmuch.grep "Message-ID" - > temp.txtsed -e 's|Message-ID:.*<\(.*\)>.*|id:\1|' temp.txt > temp1.txtsed '{:q;N;s/\n/ OR /g;t q}' temp1.txt > temp2.txt## When vi opens up list the tagging commands, e.g. +tag1 -tag2vi tags.txtTAGS=`cat tags.txt`SEARCHEXPR=`cat temp2.txt`## For debuggingecho "notmuch tag $TAGS -- $SEARCHEXPR" >> temp2.txt## Now apply the tagsnotmuch tag $TAGS -- $SEARCHEXPR# End of mutt-notmuch-tag.shThen in my .muttrc I have:
macro index <F7>"<tag-prefix><pipe-message>~/bin/mutt-notmuch-tag.sh<enter>""Tag messages (using notmuch)"On BSD systems the script fails because of gnu xargs and ln options. I changed the code to be pure perl.
You're right!
I've now proposed it for inclusion into upstream notmuch. Upstream author seems positive about it and is preparing a contrib/ directory to include it and similar tools. As soon as that happens, I'll move maintenance of the script there.
The wishlist bug report where the discussion happened is Debian bug 628018. If all goes at planned, it will soon land in Debian as a new binary package "notmuch-mutt".
Cheers.
Thanks a lot. Do you mind providing a patch against the current git repo?
I'll be happy to apply it if you do so, but note that at the moment it doesn't apply cleanly (as I've added in the meantime support for mailboxes containing spaces, which requires an extra sed pipe in between).
Many thanks in advance, Cheers.
sure, but it has nothing which is mutt-notmuch-specific.
Search results are shown in a regular mailbox, so "go back" actually just means changing to another mailbox (which might happen to be the one you were before searching or not).
I'm using mutt-patched, so I move across mailboxes through the sidebar. In regular mutt you usually do that via the "c" keybinding.
Hope this helps.