From 18c4674d437a1fd73e85ba378187ca71bbb5df2c Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sun, 31 Mar 2013 21:40:26 +0300 Subject: [PATCH] Re: [PATCH] emacs: functions to import sender or recipient into BBDB --- 1d/22f2155a9fad0e2323d8ff4f0c1076fd9c56e6 | 144 ++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 1d/22f2155a9fad0e2323d8ff4f0c1076fd9c56e6 diff --git a/1d/22f2155a9fad0e2323d8ff4f0c1076fd9c56e6 b/1d/22f2155a9fad0e2323d8ff4f0c1076fd9c56e6 new file mode 100644 index 000000000..9ddef0ab9 --- /dev/null +++ b/1d/22f2155a9fad0e2323d8ff4f0c1076fd9c56e6 @@ -0,0 +1,144 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id E5567431E64 + for ; Sun, 31 Mar 2013 11:40:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 aTEbxptbmDJ1 for ; + Sun, 31 Mar 2013 11:40:28 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 03F77431FAE + for ; Sun, 31 Mar 2013 11:40:28 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 9C347100086; + Sun, 31 Mar 2013 21:40:26 +0300 (EEST) +From: Tomi Ollila +To: Daniel Bergey , + Notmuch Mail List , + Ethan Glasser-Camp +Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB +In-Reply-To: <876207sa74.fsf@chladni.lan> +References: <87lii62sk2.fsf@wonderlust.lan> <87ipa66pne.fsf@betacantrips.com> + <87ip92zc6m.fsf@wonderlust.lan> <87ip64gdpg.fsf@chladni.lan> + <876207sa74.fsf@chladni.lan> +User-Agent: Notmuch/0.15.2+50~g43fdda5 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +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:40:29 -0000 + +On Sun, Mar 31 2013, Daniel Bergey wrote: + +>>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. +> --- + +LGTM, although git commit --amend is needed after git am to clean +the junk in commit message (just deleting content). + +Tomi + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2