Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 4e / 47b443aaf10bd9f6c2eda77a678577e65c7ba9
1 Return-Path: <bacuh@riseup.net>\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 43DC3431FAF\r
6         for <notmuch@notmuchmail.org>; Thu,  3 Jul 2014 17:48:52 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.001\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id cHPpjH8bDl8T for <notmuch@notmuchmail.org>;\r
17         Thu,  3 Jul 2014 17:48:46 -0700 (PDT)\r
18 X-Greylist: delayed 597 seconds by postgrey-1.32 at olra;\r
19         Thu, 03 Jul 2014 17:48:46 PDT\r
20 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129])\r
21         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
22         (No client certificate requested)\r
23         by olra.theworths.org (Postfix) with ESMTPS id 41E93431FAE\r
24         for <notmuch@notmuchmail.org>; Thu,  3 Jul 2014 17:48:46 -0700 (PDT)\r
25 Received: from fruiteater.riseup.net (fruiteater-pn.riseup.net [10.0.1.74])\r
26         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
27         (Client CN "*.riseup.net",\r
28         Issuer "Gandi Standard SSL CA" (not verified))\r
29         by mx1.riseup.net (Postfix) with ESMTPS id 4CF2149376;\r
30         Thu,  3 Jul 2014 17:38:48 -0700 (PDT)\r
31 Received: from [127.0.0.1] (localhost [127.0.0.1])\r
32         (Authenticated sender: bacuh@fruiteater.riseup.net)\r
33         with ESMTPSA id CDBC61016\r
34 From: Sebastian Lipp <bacuh@riseup.net>\r
35 To: Tomi Ollila <tomi.ollila@iki.fi>, David Bremner <david@tethera.net>,\r
36         Jed Brown <jed@59A2.org>, Jani Nikula <jani@nikula.org>,\r
37         Karl Fogel <kfogel@red-bean.com>, Daniel Bergey <bergey@alum.mit.edu>\r
38 Subject: Re: [PATCH] emacs: add missing paren to fix defun in\r
39         notmuch-address.el.\r
40 In-Reply-To: <m2ehejykb1.fsf@guru.guru-group.fi>\r
41 References: <87wqsfik5l.fsf@floss.red-bean.com>\r
42         <87mwtah2hd.fsf@zancas.localnet>\r
43         <877gkeau42.fsf@floss.red-bean.com>\r
44         <m2ppy5v3mc.fsf@guru.guru-group.fi> <8738v1jtzc.fsf@nikula.org>\r
45         <87k3odgutd.fsf@zancas.localnet> <87ip3wbj7g.fsf@mcs.anl.gov>\r
46         <m2hajgxli5.fsf@guru.guru-group.fi>\r
47         <87vc7vgbym.fsf@zancas.localnet>\r
48         <m2ehejykb1.fsf@guru.guru-group.fi>\r
49 User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1\r
50         (i686-pc-linux-gnu)\r
51 Date: Fri, 04 Jul 2014 02:38:51 +0200\r
52 Message-ID:\r
53  <87pphmc604.fsf@verb.i-did-not-set--mail-host-address--so-tickle-me>\r
54 MIME-Version: 1.0\r
55 Content-Type: multipart/mixed; boundary="=-=-="\r
56 X-Virus-Scanned: clamav-milter 0.98.1 at mx1\r
57 X-Virus-Status: Clean\r
58 Cc: notmuch@notmuchmail.org\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Fri, 04 Jul 2014 00:48:52 -0000\r
72 \r
73 --=-=-=\r
74 Content-Type: text/plain\r
75 \r
76 Tomi Ollila <tomi.ollila@iki.fi> writes:\r
77 > On Tue, Apr 09 2013, David Bremner wrote:\r
78 >> There seems to be a few warnings:\r
79 >>\r
80 >> In notmuch-bbdb/snarf-from:\r
81 >> notmuch-address.el:116:26:Warning: reference to free variable\r
82 >>     `bbdb-get-addresses-headers'\r
83 >>\r
84 >> In notmuch-bbdb/snarf-to:\r
85 >> notmuch-address.el:122:29:Warning: reference to free variable\r
86 >>     `bbdb-get-addresses-headers'\r
87 >>\r
88 >> In end of data:\r
89 >> notmuch-address.el:143:1:Warning: the following functions are not known to be\r
90 >>     defined: bbdb-get-addresses, bbdb-update-records, notmuch-show-get-header\r
91 >>\r
92 >> Do we need a few defvars?\r
93 >\r
94 > For the above set, something like:\r
95 >\r
96 > (defvar bbdb-get-addresses-headers)\r
97 >\r
98 > (declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
99 >\r
100 > (declare-function bbdb-get-addresses "bbdb-com" \r
101 >   (only-first-address\r
102 >    uninteresting-senders\r
103 >    get-header-content-function\r
104 >    &rest get-header-content-function-args))\r
105 >\r
106 > (declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
107 \r
108 As I'd like to see this in notmuch I made the change. The patch is\r
109 attached. As it is my first contribution to notmuch at all: Just tell me\r
110 if I'm supposed to do it in any other way.\r
111 \r
112 LG\r
113 basti\r
114 \r
115 \r
116 --=-=-=\r
117 Content-Type: text/x-diff\r
118 Content-Disposition: inline;\r
119  filename=0001-emacs-functions-to-import-sender-or-recipient-into-B.patch\r
120 \r
121 >From 522e4294258e6392a02c923b4b7e78a898986fca Mon Sep 17 00:00:00 2001\r
122 From: Daniel Bergey <bergey@alum.mit.edu>\r
123 Date: Mon, 8 Apr 2013 19:55:04 -0500\r
124 Subject: [PATCH] emacs: functions to import sender or recipient into BBDB [v3]\r
125 \r
126 >From a show buffer, notmuch-bbdb/snarf-from imports the sender into\r
127 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported\r
128 contacts are reported in the minibuffer / Messages buffer.\r
129 \r
130 Both functions use the BBDB parser to recognize email address formats.\r
131 \r
132 [v3] Fixes a few warnings as suggested by Tomi Ollila in\r
133      id:87vc7vgbym.fsf@zancas.localnet\r
134 [v2] Fixes missing close parenthesis in original.\r
135      Spotted by Karl Fogel <kfogel@red-bean.com>.\r
136 ---\r
137  emacs/notmuch-address.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++\r
138  1 file changed, 53 insertions(+)\r
139 \r
140 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
141 index fa65cd5..ee7b169 100644\r
142 --- a/emacs/notmuch-address.el\r
143 +++ b/emacs/notmuch-address.el\r
144 @@ -113,6 +113,59 @@ to know how address selection is made by default."\r
145  (when (notmuch-address-locate-command notmuch-address-command)\r
146    (notmuch-address-message-insinuate))\r
147  \r
148 +;; functions to add sender / recipients to BBDB\r
149 +\r
150 +(defvar bbdb-get-addresses-headers)\r
151 +\r
152 +(declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
153 +\r
154 +(declare-function bbdb-get-addresses "bbdb-com" \r
155 +  (only-first-address\r
156 +   uninteresting-senders\r
157 +   get-header-content-function\r
158 +   &rest get-header-content-function-args))\r
159 +\r
160 +(declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
161 +\r
162 +(defun notmuch-bbdb/snarf-headers (headers)\r
163 +  ;; Helper function to avoid code duplication in the two below\r
164 +  ;; headers should have the same format as bbdb-get-addresses-headers\r
165 +\r
166 +  ;; bbdb-get-addresses reads these\r
167 +  ;; Ugh, pass-by-global\r
168 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
169 +       (bbdb-get-addresses-headers headers) ; headers to read\r
170 +       (bbdb-gag-messages t)) ; suppress m/n processed message)\r
171 +    (bbdb-update-records addrs t t)))\r
172 +\r
173 +(defun notmuch-bbdb/snarf-from ()\r
174 +  "Import the sender of the current message into BBDB"\r
175 +  (interactive)\r
176 +  (notmuch-bbdb/snarf-headers\r
177 +   (list (assoc 'authors bbdb-get-addresses-headers))))\r
178 +\r
179 +(defun notmuch-bbdb/snarf-to ()\r
180 +  "Import all recipients of the current message into BBDB"\r
181 +  (interactive)\r
182 +  (notmuch-bbdb/snarf-headers\r
183 +   (list (assoc 'recipients bbdb-get-addresses-headers))))\r
184 +\r
185 +(defvar notmuch-bbdb/header-by-name\r
186 +  ;; both are case sensitive\r
187 +  '( ("From" . :From)\r
188 +     ("To" . :To)\r
189 +     ("CC" . :Cc)\r
190 +     ("BCC" . :Bcc)\r
191 +     ("Resent-From" . nil)\r
192 +     ("Reply-To" . nil)\r
193 +     ("Resent-To" . nil)\r
194 +     ("Resent-CC" . nil))\r
195 +  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
196 +from strings as used by bbdb-get-addresses")\r
197 +\r
198 +(defun notmuch-bbdb/get-header-content (name)\r
199 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
200 +\r
201  ;;\r
202  \r
203  (provide 'notmuch-address)\r
204 -- \r
205 2.0.1\r
206 \r
207 \r
208 --=-=-=--\r