Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 22 / f68f2e0d40a7ee143c839ef9e5047b3279a919
1 Return-Path: <five9a2@gmail.com>\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 6EA01431FB6\r
6         for <notmuch@notmuchmail.org>; Mon,  8 Apr 2013 18:12:40 -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.301\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.301 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, \r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 j4y2+773o4Kq for <notmuch@notmuchmail.org>;\r
17         Mon,  8 Apr 2013 18:12:39 -0700 (PDT)\r
18 Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com\r
19         [209.85.223.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id B002F431FAE\r
22         for <notmuch@notmuchmail.org>; Mon,  8 Apr 2013 18:12:39 -0700 (PDT)\r
23 Received: by mail-ie0-f171.google.com with SMTP id e14so7873651iej.30\r
24         for <notmuch@notmuchmail.org>; Mon, 08 Apr 2013 18:12:39 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:sender:from:to:cc:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=1AGfDchkhsWQvs66oviCZQsIxADueajtPP7OPxaaO6E=;\r
29         b=svAB6DHkteCSRIExtN18wRdxHR5zGB/XnI5RvmGFEOldKG7nKZhTVBB9f0l8eG/ZTl\r
30         5cw7xTFtYm9z/o4v88MXLTX5nbT/oAd57AMuhEZ0z84CDeER/NdvX9r8JjLS1pOHPUjh\r
31         g3BIKcRL9lzF5naMxbw6R3z0PKRbBCDvEH2R/68rlDIVGBMcMbxzOO5E1uKJt4+QYs0H\r
32         t7eAc4uAg8nPL46IdJs0GapzUG40cbD/JsL0uFD0voaUB2apmWa3SS5n9B+taArPwX34\r
33         GfdX9pC3J88ZHqh0G/SzkHqvU8Gw4dtSgC70U0tYg5b/9mEMSqCjE3hkZm6gvKbPzK94\r
34         ck4Q==\r
35 X-Received: by 10.50.114.37 with SMTP id jd5mr9345489igb.2.1365469957953;\r
36         Mon, 08 Apr 2013 18:12:37 -0700 (PDT)\r
37 Received: from localhost ([38.69.41.96])\r
38         by mx.google.com with ESMTPS id y5sm22761884igg.7.2013.04.08.18.12.36\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Mon, 08 Apr 2013 18:12:37 -0700 (PDT)\r
41 Sender: Jed Brown <five9a2@gmail.com>\r
42 From: Jed Brown <jed@59A2.org>\r
43 To: David Bremner <david@tethera.net>, Jani Nikula <jani@nikula.org>,\r
44         Tomi Ollila <tomi.ollila@iki.fi>, Karl Fogel <kfogel@red-bean.com>,\r
45         Daniel Bergey <bergey@alum.mit.edu>\r
46 Subject: Re: [PATCH] emacs: add missing paren to fix defun in\r
47         notmuch-address.el.\r
48 In-Reply-To: <87k3odgutd.fsf@zancas.localnet>\r
49 References: <87wqsfik5l.fsf@floss.red-bean.com>\r
50         <87mwtah2hd.fsf@zancas.localnet>\r
51         <877gkeau42.fsf@floss.red-bean.com>\r
52         <m2ppy5v3mc.fsf@guru.guru-group.fi> <8738v1jtzc.fsf@nikula.org>\r
53         <87k3odgutd.fsf@zancas.localnet>\r
54 User-Agent: Notmuch/0.15.2+78~g5404ac5 (http://notmuchmail.org) Emacs/24.3.1\r
55         (x86_64-unknown-linux-gnu)\r
56 Date: Mon, 08 Apr 2013 20:12:35 -0500\r
57 Message-ID: <87ip3wbj7g.fsf@mcs.anl.gov>\r
58 MIME-Version: 1.0\r
59 Content-Type: multipart/mixed; boundary="=-=-="\r
60 Cc: notmuch@notmuchmail.org\r
61 X-BeenThere: notmuch@notmuchmail.org\r
62 X-Mailman-Version: 2.1.13\r
63 Precedence: list\r
64 List-Id: "Use and development of the notmuch mail system."\r
65         <notmuch.notmuchmail.org>\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
69 List-Post: <mailto:notmuch@notmuchmail.org>\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
73 X-List-Received-Date: Tue, 09 Apr 2013 01:12:40 -0000\r
74 \r
75 --=-=-=\r
76 Content-Type: text/plain\r
77 \r
78 David Bremner <david@tethera.net> writes:\r
79 \r
80 > Squashed sounds good to me too. Sorry I'm too lazy/busy at the moment to\r
81 > do it myself.\r
82 \r
83 I tested the attached and it's working as expected.  Sent as an\r
84 attachment to preserve author information.\r
85 \r
86 \r
87 --=-=-=\r
88 Content-Type: text/x-patch\r
89 Content-Disposition: inline;\r
90  filename=0001-emacs-functions-to-import-sender-or-recipient-into-B.patch\r
91 \r
92 >From 5404ac5bf13f8b5349d5b94f9f2000e9d1832b83 Mon Sep 17 00:00:00 2001\r
93 From: Daniel Bergey <bergey@alum.mit.edu>\r
94 Date: Mon, 8 Apr 2013 19:55:04 -0500\r
95 Subject: [PATCH] emacs: functions to import sender or recipient into BBDB [v2]\r
96 \r
97 >From a show buffer, notmuch-bbdb/snarf-from imports the sender into\r
98 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported\r
99 contacts are reported in the minibuffer / Messages buffer.\r
100 \r
101 Both functions use the BBDB parser to recognize email address formats.\r
102 \r
103 [v2] Fixes missing close parenthesis in original.\r
104      Spotted by Karl Fogel <kfogel@red-bean.com>.\r
105 ---\r
106  emacs/notmuch-address.el | 41 +++++++++++++++++++++++++++++++++++++++++\r
107  1 file changed, 41 insertions(+)\r
108 \r
109 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
110 index 2bf762b..4eda098 100644\r
111 --- a/emacs/notmuch-address.el\r
112 +++ b/emacs/notmuch-address.el\r
113 @@ -96,6 +96,47 @@ line."\r
114  (when (notmuch-address-locate-command notmuch-address-command)\r
115    (notmuch-address-message-insinuate))\r
116  \r
117 +;; functions to add sender / recipients to BBDB\r
118 +\r
119 +(defun notmuch-bbdb/snarf-headers (headers)\r
120 +  ;; Helper function to avoid code duplication in the two below\r
121 +  ;; headers should have the same format as bbdb-get-addresses-headers\r
122 +\r
123 +  ;; bbdb-get-addresses reads these\r
124 +  ;; Ugh, pass-by-global\r
125 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
126 +       (bbdb-get-addresses-headers headers) ; headers to read\r
127 +       (bbdb-gag-messages t)) ; suppress m/n processed message)\r
128 +    (bbdb-update-records addrs t t)))\r
129 +\r
130 +(defun notmuch-bbdb/snarf-from ()\r
131 +  "Import the sender of the current message into BBDB"\r
132 +  (interactive)\r
133 +  (notmuch-bbdb/snarf-headers\r
134 +   (list (assoc 'authors bbdb-get-addresses-headers))))\r
135 +\r
136 +(defun notmuch-bbdb/snarf-to ()\r
137 +  "Import all recipients of the current message into BBDB"\r
138 +  (interactive)\r
139 +  (notmuch-bbdb/snarf-headers\r
140 +   (list (assoc 'recipients bbdb-get-addresses-headers))))\r
141 +\r
142 +(defvar notmuch-bbdb/header-by-name\r
143 +  ;; both are case sensitive\r
144 +  '( ("From" . :From)\r
145 +     ("To" . :To)\r
146 +     ("CC" . :Cc)\r
147 +     ("BCC" . :Bcc)\r
148 +     ("Resent-From" . nil)\r
149 +     ("Reply-To" . nil)\r
150 +     ("Resent-To" . nil)\r
151 +     ("Resent-CC" . nil))\r
152 +  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
153 +from strings as used by bbdb-get-addresses")\r
154 +\r
155 +(defun notmuch-bbdb/get-header-content (name)\r
156 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
157 +\r
158  ;;\r
159  \r
160  (provide 'notmuch-address)\r
161 -- \r
162 1.8.2.1\r
163 \r
164 \r
165 --=-=-=--\r