[notmuch] My shiny new notmuch configuration
Ben Gamari
bgamari.foss at gmail.com
Thu Mar 11 07:24:05 PST 2010
Hey all,
After standing on the sidelines for several months now, I've finally transitioned to
using notmuch exclusively. I had originally intended on waiting until the vim was
in a usable state, but it seems that the emacs client is usable enough for
basic mail reading for the time being. It took a bit of thinking to figure out
how thing should be implemented, but I think it turned out alright. There are
still a few sticky spots, but hopefully I'll be able to iron those out in time.
Regardless, I couldn't sacrifice my preference for vim for email composition and
therefore have been using a small wrapper script[10] to begin new drafts. I
also have a small python script[12] so that I can make use of my old sup address
book. Finally, I have a script for sending a draft and placing it in my sent
maildir. My tagging script[13] is very similar to those posted here before.
All-in-all, things seem very usable and I'm quite happy with how my notmuch
configuration has turned out. It will be very nice with a real vim interface, which I'll
hopefully have time to work on in May or so.
Unfortunately, both notmuch new and the initial tagging process are a bit slower
than I would like (with fairly warm caches notmuch new just took 20 seconds to
add 2 messages, which then took an additional 45 seconds to tag) but still
usable. I believe I should have the newest Xapian bits so I guess figuring out
the issue here could require some investigation.
In the meantime, I've done a some hacking on the noneatall[1] web interface
that was posted here a little while ago, restructing the code a little and
adding a tag list. I intend doing more work on this in the future. At the
moment the latency really kills usability, but with some work I suspect a web
interface might be very usable.
I hope that someone finds this at least slightly useful.
Cheers,
- Ben
[1] 874okzdgh0.fsf at aw.hh.sledj.ne
[10] compose-mail
#!/bin/bash
cd ~/.mail/.drafts
TO=$(contacts $@)
gvim - +3 -c'set syntax=mail' <<EOF
From: Ben Gamari <bgamari at gmail.com>
To: ${TO}
Subject:
EOF
[11] contacts
#!/usr/bin/python
# Simple address book lookup:
# Usage: contacts.py [alias]
# Outputs: Full Name <Email at address>
import os
import sys
contacts_file = os.path.expanduser('~/.contacts')
def get():
contacts = {}
for l in open(contacts_file, 'r'):
name,address = l.split(':')
contacts[name.strip()] = address.strip()
return contacts
if __name__ == '__main__':
contacts = get()
m = []
m = [ contacts.get(name, name) for name in sys.argv[1:] ]
print ", ".join(m)
[13] sort-mail
#!/usr/bin/python
dry_run = False
import subprocess
import time
def sf_list(name):
return 'to:%s at lists.sourceforge.net or to:%s at lists.sf.net' % (name, name)
def kernel_list(name):
return 'to:%s at vger.kernel.org' % name
def fdo_list(name):
return 'to:%s at lists.freedesktop.org' % name
# These are bulk message sources which should be immediately archived
list_tags = {
kernel_list('linux-kernel'): 'lkml',
kernel_list('linux-omap') : 'linux-omap',
kernel_list('linux-next'): 'linux-next',
'to:linux-arm-kernel at lists.infradead.org': 'linux-arm',
sf_list('oprofile-list'): 'oprofile',
sf_list('ipw3945-devel'): 'ipw',
'to:hostap at lists.shmoo.com': 'hostap',
'to:ath9k-devel@': 'ath9k',
'to:vim-dev at vim.org': 'vim',
fdo_list('intel-gfx'): 'intel-gfx',
fdo_list('xorg'): 'xorg',
fdo_list('hal'): 'hal',
fdo_list('compiz'): 'compiz',
sf_list('dri-devel'): 'dri',
sf_list('dri-users'): 'dri',
sf_list('mesa3d-dev'): 'mesa',
fdo_list('devkit-devel'): 'devkit',
sf_list('matplotlib-users'): 'matplotlib',
'to:notmuch at notmuchmail.org': 'notmuch',
'to:openembedded-devel at lists.openembedded.org': 'openembedded',
'to:beagleboard at googlegroups.com': 'beagleboard',
'to:angstrom-distro-devel at linuxtogo.org': 'angstrom',
'to:angstrom-distro-users at linuxtogo.org': 'angstrom',
'to:mono-devel-list at lists.ximian.com': 'mono',
'to:mono-list@': 'mono',
'to:ubuntu-devel-discuss at lists.ubuntu.com': 'ubuntu-devel',
'to:git at vger.kernel.org': 'git',
'to:sup-talk at rubyforge.org': 'sup',
'from:bugzilla': 'bugs',
'to:gdh at gdhour.com': 'gdh',
'from:Facebook': 'facebook',
}
# Tags that aren't for lists
generic_tags = {
'from:goldner': 'lori',
'to:goldnerlab': 'lori',
'to:babaev1 at physics.umass.edu': 'stat-mech',
'to:pgradon at physics.umass.edu': 'pgradon',
}
def notmuch(*args):
cmd = ['notmuch']
cmd.extend(args)
print ' '.join(cmd)
if dry_run: return
while True:
res = subprocess.call(cmd)
if res == 0: break
print "Call failed. Trying again in 1 second..."
time.sleep(1)
# Tag things
for terms, tag in generic_tags.items():
notmuch('tag', '+%s' % tag, 'tag:inbox', terms)
# Tag lists
for terms, tag in list_tags.items():
notmuch('tag', '+list', '+%s' % tag, 'tag:inbox', terms)
# Remove inbox for lists
for terms, tag in list_tags.items():
notmuch('tag', '-inbox', 'tag:inbox', terms)
More information about the notmuch
mailing list