Re: [PATCH] emacs: functions to import sender or recipient into BBDB

Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB

Date: Sun, 18 Nov 2012 19:08:49 -0500

To: Notmuch Mail List, Ethan Glasser-Camp


From: Daniel Bergey

On 2012-10-19 at 18:52, Ethan Glasser-Camp <> wrote:
> Daniel Bergey <> writes:
>> From a show buffer, bbdb/notmuch-snarf-from imports the sender into
>> bbdb.  bbdb/notmuch-snarf-to attempts to import all recipients.  BBDB
>> displays a buffer with each contact; C-g displays the next contact, or
>> returns to the notmuch-show buffer.
>> This is my first notmuch patch.  Comments very welcome.
>> +(defun bbdb/snarf-between-commas ()
>> +  ; What about names written "Surname, First M" <user@server.tld>?
> I do think more sophisticated parsing is necessary. If you're lucky,
> somebody else already has a library to parse email addresses in this
> form.

I spent the afternoon digging around in BBDB internals.  They include a
function that parses the contents of a header, and handles commas
intelligently.  It replaces essentially all the code in my small patch,
so I won't respond to your detailed comments, much as I appreciated

I have working code using bbdb-get-addresses, but I have a few questions
before I email the revised patch.

1) Is there a canonical list of header names used by notmuch?  I'm
trying to fill in this alist to match the BBDB interface.  It should be
fine to leave blank any that notmuch doesn't handle.

(defvar bbdb/notmuch-header-by-name
  ;; both are case sensitive
  '( ("From" . :From)
	("To" . :To)
	("CC" . :Cc)
	("BCC" . :Bcc)
	("Resent-From" . )
	("Reply-To" . )
	("Resent-To" . )
	("Resent-CC" . ))
  "Alist for dispatching header symbols as used by notmuch-show-get-header
from strings as used by notmuch-show-get-header")

2) What's the consensus on naming conventions?  BBDB has functions for
other mail clients with names like bbdb/gnus-* and bbdb/vm-*.  I
imitated this convention, but maybe it's better to leave the bbdb/*
namespace to BBDB itself, and use a prefix like notmuch-bbdb-* or
notmuch-bbdb/* (Regardless, I moved everything to notmuch-address.el, as