--- /dev/null
+Return-Path: <bergey@alum.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 4BEE1429E25\r
+ for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 06:47:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.69\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.69 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ T_MIME_NO_TEXT=0.01] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id B4fkGodvdu4E for <notmuch@notmuchmail.org>;\r
+ Thu, 12 Jul 2012 06:47:38 -0700 (PDT)\r
+Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com\r
+ [66.111.4.27])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 7FFC1431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 06:47:38 -0700 (PDT)\r
+Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42])\r
+ by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 494D1211AC;\r
+ Thu, 12 Jul 2012 09:47:36 -0400 (EDT)\r
+Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160])\r
+ by compute2.internal (MEProxy); Thu, 12 Jul 2012 09:47:36 -0400\r
+DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=\r
+ messagingengine.com; h=from:to:subject:in-reply-to:references\r
+ :date:message-id:mime-version:content-type; s=smtpout; bh=5fUly6\r
+ 5K51AZlFKQWbovB6UjyaU=; b=ugBZvt0c42pgnqAbqj6vQIN7dzDa3JgLKss1cV\r
+ G0w2mWOSaYChLLbm+3mJurEpMYFdeq5OEYjEP58FdIlDOSGV/aevYWBEfyT6rtIA\r
+ M4N91R3aJcG4qL2J/3f0OrlskZJzXDYFRw69quRqlndwiJPYEDcezYXk2RiTcuCV\r
+ /VnLk=\r
+X-Sasl-enc: SnTONlIDQJ/DBV6i4p5vQqEPaoSvEu/VbZTx2GcRX9z5 1342100855\r
+Received: from localhost (unknown [66.80.90.109])\r
+ by mail.messagingengine.com (Postfix) with ESMTPA id 7D8888E00F9;\r
+ Thu, 12 Jul 2012 09:47:35 -0400 (EDT)\r
+From: Daniel Bergey <bergey@alum.mit.edu>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
+ notmuch@notmuchmail.org\r
+Subject: Re: notmuch-emacs and bbdb\r
+In-Reply-To: <87mx35pji9.fsf@servo.finestructure.net>\r
+References: <878ver1jp0.fsf@wonderlust.lan>\r
+ <87mx35pji9.fsf@servo.finestructure.net>\r
+User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Thu, 12 Jul 2012 09:47:34 -0400\r
+Message-ID: <87txxdytu1.fsf@wonderlust.lan>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/mixed; boundary="=-=-="\r
+X-Mailman-Approved-At: Thu, 12 Jul 2012 10:59:07 -0700\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 12 Jul 2012 13:47:39 -0000\r
+\r
+--=-=-=\r
+\r
+I hacked together the attached elisp yesterday. It provides bindings to\r
+put sender or recipients into bbdb. (Recipients part needs more\r
+testing.) It also colors the from line green if the sender is in bbdb,\r
+or orange otherwise. When it's been through a bit more testing, I'll\r
+submit at least the first part as a patch.\r
+\r
+I prefer not to autocapture everything into bbdb, and for the same\r
+reason, I don't want to use notmuch itself as my contacts DB. Mostly,\r
+this is because I read lots of email on lists, sent by people I'm\r
+unlikely to write back to. I don't like every John I've heard from\r
+coming up on autocomplete. Other reasons include sync to phone and\r
+adding contact information from channels other than email.\r
+\r
+bergey\r
+\r
+\r
+--=-=-=\r
+Content-Type: application/emacs-lisp\r
+Content-Disposition: attachment; filename=bbdb-notmuch.el\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+; capture addresses=20\r
+(defun bbdb/notmuch-snarf-header (header)\r
+ (let ((text (notmuch-show-get-header header)))\r
+ (with-temp-buffer\r
+ (insert text)\r
+ (bbdb-snarf-region (point-min) (point-max)))))\r
+\r
+(defun bbdb/notmuch-snarf-from ()\r
+ (interactive)\r
+ (bbdb/notmuch-snarf-header :From))\r
+\r
+(defun bbdb/notmuch-snarf-to ()\r
+ (interactive)\r
+ (bbdb/notmuch-snarf-header :To))\r
+\r
+(define-key notmuch-show-mode-map "b" 'bbdb/notmuch-snarf-from)\r
+(define-key notmuch-show-mode-map "B" 'bbdb/notmuch-snarf-to)\r
+\r
+;; color from line according to known / unknown sender\r
+; code taken from bbdb-gnus.el\r
+(defun bbdb/notmuch-known-sender ()\r
+ (let* ((from (plist-get headers :From))\r
+ (splits (mail-extract-address-components from))\r
+ (name (car splits))\r
+ (net (cadr splits))\r
+ (record (and splits\r
+ (bbdb-search-simple\r
+ name\r
+ (if (and net bbdb-canonicalize-net-hook)\r
+ (bbdb-canonicalize-address net)\r
+ net)))))\r
+ (and record net (member (downcase net) (bbdb-record-net record)))))\r
+\r
+(defun bbdb/check-known-sender ()\r
+ (interactive)\r
+ (if (bbdb/notmuch-known-sender) (message "Sender is known") (message "Sen=\r
+der is not known")))\r
+\r
+(defface notmuch-show-known-addr\r
+ '(\r
+ (((class color) (background dark)) :foreground "spring green")\r
+ (((class color) (background light)) :background "spring green" :foregro=\r
+und "black"))\r
+ "Face for sender or recipient already listed in bbdb"\r
+ :group 'notmuch-show\r
+ :group 'notmuch-faces)\r
+\r
+(defface notmuch-show-unknown-addr\r
+ '(\r
+ (((class color) (background dark)) :foreground "dark orange")\r
+ (((class color) (background light)) :background "gold" :foreground "bla=\r
+ck"))\r
+ "Face for sender or recipient not listed in bbdb"\r
+ :group 'notmuch-show\r
+ :group 'notmuch-faces)\r
+\r
+; override function from notmuch-show\r
+(defun notmuch-show-insert-headerline (headers date tags depth)\r
+ "Insert a notmuch style headerline based on HEADERS for a\r
+message at DEPTH in the current thread."\r
+ (let ((start (point))\r
+ (face (if (bbdb/notmuch-known-sender) 'notmuch-show-known-addr 'not=\r
+much-show-unknown-addr))\r
+ (end-from))\r
+ (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width de=\r
+pth))\r
+ (notmuch-show-clean-address (plist-get headers :From)))\r
+ (setq end-from (point))\r
+ (insert\r
+ " ("\r
+ date\r
+ ") ("\r
+ (propertize (mapconcat 'identity tags " ")\r
+ 'face 'notmuch-tag-face)\r
+ ")\n")\r
+ (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summar=\r
+y-face)\r
+ (save-excursion\r
+ (goto-char start)\r
+ (overlay-put (make-overlay start end-from) 'face face))))\r
+\r
+\r
+--=-=-=\r
+\r
+\r
+\r
+Jameson Graef Rollins <jrollins@finestructure.net> writes:\r
+\r
+> On Tue, Jul 10 2012, Daniel Bergey <bergey@alum.mit.edu> wrote:\r
+>> As far as I can tell, notmuch doesn't integrate as smoothly with bbdb as older\r
+>> emacs mailclients. I'm especially looking for a snarf function that\r
+>> distinguishes sender from recipient.\r
+>>\r
+>> How do other people use bbdb with notmuch?\r
+>>\r
+>> Does anyone have lisp code like that which ships with bbdb for other\r
+>> clients?\r
+>>\r
+>> If I were to find time to write such code, what would you like it to do?\r
+>\r
+> Hey, Bergey. This is something that I think needs improvement as well.\r
+> I've been just manually constructing the bbdb entries myself.\r
+>\r
+> But what I've really been meaning to get going is address\r
+> auto-completion from the database, which I'm pretty sure could obviate\r
+> my need for bbdb altogether:\r
+>\r
+> http://notmuchmail.org/emacstips/#index13h2\r
+>\r
+> Getting it working seems more difficult than it should be, though, and\r
+> the existing solutions seem a bit slower than they need to be [0]. So I\r
+> think there's also room for improvement here.\r
+>\r
+> For instance, I think it would be rad if notmuch provided this\r
+> functionality natively, in the CLI, or even in the library [1]. I think\r
+> it's definitely doable, and it would be a nice little project.\r
+>\r
+> The emacs integration could be a bit smoother as well. A single config\r
+> option should either turn the functionality on or off. That would be\r
+> very convenient [2].\r
+>\r
+> jamie.\r
+>\r
+> [0] id:"87r4xur3rv.fsf@plc.plecavalier.com"\r
+> [1] For what it's worth, I would prefer a solution that didn't involve\r
+> any caching of addresses outside of the database.\r
+> [2] I also find it changes the behavior of the ido tab completion\r
+> interface that I'm used to using in message mode.\r
+\r
+--=-=-=--\r