From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7E55B431E64 for ; Sun, 31 Mar 2013 11:19:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i-qua1VZAZwy for ; Sun, 31 Mar 2013 11:19:46 -0700 (PDT) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 5FF7C431FAE for ; Sun, 31 Mar 2013 11:19:46 -0700 (PDT) Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 75A302078F; Sun, 31 Mar 2013 14:19:45 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute4.internal (MEProxy); Sun, 31 Mar 2013 14:19:45 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:in-reply-to:references :date:message-id:mime-version:content-type; s=smtpout; bh=dQ8Umu pqlC9tBJ7ttuImC8kiypE=; b=NQ63R9RaQYriUXwuF6i5Wd5R7lu1P/UG9/0V+M X11vmBjS2P85yqFufRhW0w17A5EqN5iBIAB51Fhn9my21sgld2oJxEF0zxRPMxAD eLOje9UNHOftAr45i9Lqhfdc/nxYJLXn1CA3zke9xgVz9UZewGOGG+XileIcJGLL BKhDM= X-Sasl-enc: SiWuNpGwiEpBfwiSr8Y5GBMRs0TtUgDEZ2f/o1WxtUdJ 1364753985 Received: from localhost (unknown [66.80.90.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 215452000D3; Sun, 31 Mar 2013 14:19:45 -0400 (EDT) From: Daniel Bergey To: Tomi Ollila , Notmuch Mail List , Ethan Glasser-Camp Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB In-Reply-To: References: <87lii62sk2.fsf@wonderlust.lan> <87ipa66pne.fsf@betacantrips.com> <87ip92zc6m.fsf@wonderlust.lan> <87ip64gdpg.fsf@chladni.lan> User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/24.2.1 (x86_64-pc-linux-gnu) Date: Sun, 31 Mar 2013 14:20:15 -0400 Message-ID: <876207sa74.fsf@chladni.lan> MIME-Version: 1.0 Content-Type: text/plain Cc: Chris Thachuk X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2013 18:19:50 -0000 >From fbaf5c568876a6f1e3d8c02446bd83331b6325f0 Mon Sep 17 00:00:00 2001 From: Daniel Bergey Date: Thu, 26 Jul 2012 15:44:01 -0400 Subject: [PATCH] emacs: functions to import sender or recipients into BBDB >From a show buffer, notmuch-bbdb/snarf-from imports the sender into bbdb. notmuch-bbdb/snarf-to imports all recipients. Newly imported contacts are reported in the minibuffer / Messages buffer. Both functions use the BBDB parser to recognize email address formats. --- This differs from the last version of the patch only in whitespace. In addition to changes pointed out by Tomi Ollila, I fixed a ')' on a line alone, and aligned the lines of notmuch-bbdb/header-by-name. I've been using this code (prior to whitespace changes) for a month and a half, as far as testing goes. I wonder if I can get whitespace-mode to warn me about double-spacing.... emacs/notmuch-address.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 2bf762b..32c8490 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -96,6 +96,47 @@ line." (when (notmuch-address-locate-command notmuch-address-command) (notmuch-address-message-insinuate)) +;; functions to add sender / recipients to BBDB + +(defun notmuch-bbdb/snarf-headers (headers) + ;; Helper function to avoid code duplication in the two below + ;; headers should have the same format as bbdb-get-addresses-headers + + ;; bbdb-get-addresses reads these + ;; Ugh, pass-by-global + (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content)) + (bbdb-get-addresses-headers headers) ; headers to read + (bbdb-gag-messages t)) ; suppress m/n processed message) + (bbdb-update-records addrs t t)) + + (defun notmuch-bbdb/snarf-from () + "Import the sender of the current message into BBDB" + (interactive) + (notmuch-bbdb/snarf-headers + (list (assoc 'authors bbdb-get-addresses-headers)))) + +(defun notmuch-bbdb/snarf-to () + "Import all recipients of the current message into BBDB" + (interactive) + (notmuch-bbdb/snarf-headers + (list (assoc 'recipients bbdb-get-addresses-headers)))) + +(defvar notmuch-bbdb/header-by-name + ;; both are case sensitive + '( ("From" . :From) + ("To" . :To) + ("CC" . :Cc) + ("BCC" . :Bcc) + ("Resent-From" . nil) + ("Reply-To" . nil) + ("Resent-To" . nil) + ("Resent-CC" . nil)) + "Alist for dispatching header symbols as used by notmuch-show-get-header +from strings as used by bbdb-get-addresses") + +(defun notmuch-bbdb/get-header-content (name) + (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name)))) + ;; (provide 'notmuch-address) -- 1.7.10.4