1 Return-Path: <tomi.ollila@iki.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id B59A9431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 18 Feb 2013 23:25:06 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id EUiS5Bevw9ZW for <notmuch@notmuchmail.org>;
\r
16 Mon, 18 Feb 2013 23:25:04 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 4EFC1431FAF
\r
19 for <notmuch@notmuchmail.org>; Mon, 18 Feb 2013 23:25:04 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id 6CE7310014F;
\r
22 Tue, 19 Feb 2013 09:24:51 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Daniel Bergey <bergey@alum.mit.edu>,
\r
25 Notmuch Mail List <notmuch@notmuchmail.org>,
\r
26 Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>
\r
27 Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB
\r
28 In-Reply-To: <87ip64gdpg.fsf@chladni.lan>
\r
29 References: <87lii62sk2.fsf@wonderlust.lan> <87ipa66pne.fsf@betacantrips.com>
\r
30 <87ip92zc6m.fsf@wonderlust.lan> <87ip64gdpg.fsf@chladni.lan>
\r
31 User-Agent: Notmuch/0.15+20~g7e29ae9 (http://notmuchmail.org) Emacs/24.2.1
\r
32 (x86_64-unknown-linux-gnu)
\r
33 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
34 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
35 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
36 Date: Tue, 19 Feb 2013 09:24:51 +0200
\r
37 Message-ID: <m21uccsr3w.fsf@guru.guru-group.fi>
\r
39 Content-Type: text/plain
\r
40 Cc: Chris Thachuk <chris.thachuk@cs.ox.ac.uk>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Tue, 19 Feb 2013 07:25:06 -0000
\r
55 On Thu, Feb 07 2013, Daniel Bergey wrote:
\r
57 >>From a show buffer, notmuch-bbdb/snarf-from imports the sender into
\r
58 > bbdb. notmuch-bbdb/snarf-to imports all recipients. Newly imported
\r
59 > concacts are reported in the minibuffer / Messages buffer.
\r
61 > Both functions use the BBDB parser to recognize email address formats.
\r
63 > Following discussion upthread, I put everything in notmuch-address. I
\r
64 > renamed the functions to put notmuch before bbdb. And I replaced the
\r
65 > horrid comma-splitting from my first version with the functions BBDB
\r
66 > provides for parsing email headers.
\r
68 > It looks as though Reply-To is not exposed in the :headers plist. I
\r
69 > assume the Resent-* headers are not, either. Therefore none of these
\r
70 > are imported (nil entries in notmuch-bbdb/header-by-name). They would be
\r
71 > easy to add if the plist is expanded.
\r
73 > Thanks, and sorry it's taken me so long to get back to this patch.
\r
75 >From my understanding the code looks pretty good; I have only some
\r
76 whitespace consistency things that jist briefly passes the threshold
\r
77 to mention -- comments inline.
\r
79 But before doing a potential cleanup patch the users of notmuch-bbdb
\r
80 please test and comment
\r
82 > emacs/notmuch-address.el | 43 +++++++++++++++++++++++++++++++++++++++++++
\r
83 > 1 file changed, 43 insertions(+)
\r
85 > diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
\r
86 > index 2bf762b..8d5f727 100644
\r
87 > --- a/emacs/notmuch-address.el
\r
88 > +++ b/emacs/notmuch-address.el
\r
89 > @@ -98,4 +98,47 @@ line."
\r
93 This ';;' used to be 3rd last line in notmuch-address.el.
\r
94 Running 'tail -n 5 emacs/*.el' reveals that it is (somewhat) consistent
\r
95 to use it as "separator" between code above and (provide 'notmuch-...)
\r
98 > +;; functions to add sender / recipients to BBDB
\r
100 > +(defun notmuch-bbdb/snarf-headers (headers)
\r
101 > + ;; Helper function to avoid code duplication in the two below
\r
102 > + ;; headers should have the same format as bbdb-get-addresses-headers
\r
104 > + ;; bbdb-get-addresses reads these
\r
105 > + ;; Ugh, pass-by-global
\r
106 > + (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))
\r
107 > + (bbdb-get-addresses-headers headers) ; headers to read
\r
108 > + (bbdb-gag-messages t) ; suppress m/n processed message
\r
110 > + (bbdb-update-records addrs t t)))
\r
112 > +(defun notmuch-bbdb/snarf-from ()
\r
113 > + "Import the sender of the current message into BBDB"
\r
115 > + (notmuch-bbdb/snarf-headers
\r
116 > + (list (assoc 'authors bbdb-get-addresses-headers))))
\r
121 > +(defun notmuch-bbdb/snarf-to ()
\r
122 > + "Import all recipients of the current message into BBDB"
\r
124 > + (notmuch-bbdb/snarf-headers
\r
125 > + (list (assoc 'recipients bbdb-get-addresses-headers))))
\r
130 > +(defvar notmuch-bbdb/header-by-name
\r
131 > + ;; both are case sensitive
\r
132 > + '( ("From" . :From)
\r
136 > + ("Resent-From" . nil)
\r
137 > + ("Reply-To" . nil)
\r
138 > + ("Resent-To" . nil)
\r
139 > + ("Resent-CC" . nil))
\r
140 > + "Alist for dispatching header symbols as used by notmuch-show-get-header
\r
141 > +from strings as used by bbdb-get-addresses")
\r
143 > +(defun notmuch-bbdb/get-header-content (name)
\r
144 > + (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))
\r
148 2 empty lines --- somewhat consistent with notmuch-lib.el ... but
\r
149 not with anything else ;D
\r
151 > (provide 'notmuch-address)
\r