[notmuch] Using notmuch as an address book for tab-completion

Jesse Rosenthal jrosenthal at jhu.edu
Sat Mar 20 19:35:42 PDT 2010


Dear All,

There was some talk on IRC ages ago about using notmuch as an
address-book for tab-completion in emacs message mode. Thanks to some
great recent work (Ingmar Vanhassel's shared lib and Sebastians's
cnotmuch python lib) I have been able to take a first step in that
direction. I've written a python script (with some help and suggestions
from spaetz) which can perform the address-book functionality, and a
backend for emacs's EUDC address-lookup functionality to access the
script.

They are available by the following commands:

git clone http://jkr.acm.jhu.edu/git/notmuch_addresses.git
git clone http://jkr.acm.jhu.edu/git/notmuch_eudc.git

Remember, neither of these will do you much good with the shared lib and
cnotmuch installed.

At the moment, the script works by search addresses that you have
written to (or CC'd or BCC'd) in the past. This seems like a good
utility-speed tradeoff, but it would be easy to hack the script to
search a different set of messages. Give three letters (it looks through
first names, last names, and email addresses) it returns results from my
12K messages in well under a second. 

The responses are sorted by frequency, and each email address is
associated with the most frequently used real name (null real-names are
avoided, unless they're the only option).

The script can be run from the command line by:
$ python notmuch_addresses.py query

To get tab completion from emacs, you have to install the script into
your path, make it executable, and then put my eudcb-notmuch.el file
into your load path (you should byte-compile it too). DON'T CHANGE THE
TITLE OF THE .EL FILE! EUDC looks for a specific title based on
protocol.

Then add the following to your .emacs:

(eudc-set-server "localhost" 'notmuch t)
(setq eudc-server-hotlist '(("localhost" . notmuch)))
(setq eudc-inline-expansion-servers 'hotlist)

if you wish to use BBDB too (likely before you use notmuch), then
you should use something like this:

(eudc-set-server "localhost" 'bbdb t)
(eudc-protocol-set 'eudc-inline-expansion-format 
		   '("%s %s <%s>" firstname lastname net)
		   'bbdb)
(eudc-set-server "localhost" 'notmuch t)
(setq eudc-server-hotlist '(("localhost" . bbdb)
			    ("localhost" . notmuch)))
(setq eudc-inline-expansion-servers 'hotlist)

That should do it. Please let me know if it works for you.

(For those of you who care, eudcb-notmuch.el has a few hacky bits to
hide the fact that notmuch really isn't an address book. That is, it
doesn't know the difference between names and email addresses. So
everything you enter just goes in as one string, which I call "name."
Back-end stuff, but if you're looking through the code, that might make
a few things clearer.)

Best,
Jesse


More information about the notmuch mailing list