Re: Getting the right root mail of the thread
[notmuch-archives.git] / 10 / 71073fafa5a0beb1e322b3868176e168c03c15
1 Return-Path: <bergey@alum.mit.edu>\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 7E55B431E64\r
6         for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 11:19:50 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7]\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 i-qua1VZAZwy for <notmuch@notmuchmail.org>;\r
17         Sun, 31 Mar 2013 11:19:46 -0700 (PDT)\r
18 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com\r
19         [66.111.4.25])\r
20         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 5FF7C431FAE\r
23         for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 11:19:46 -0700 (PDT)\r
24 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44])\r
25         by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 75A302078F;\r
26         Sun, 31 Mar 2013 14:19:45 -0400 (EDT)\r
27 Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161])\r
28         by compute4.internal (MEProxy); Sun, 31 Mar 2013 14:19:45 -0400\r
29 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=\r
30         messagingengine.com; h=from:to:cc:subject:in-reply-to:references\r
31         :date:message-id:mime-version:content-type; s=smtpout; bh=dQ8Umu\r
32         pqlC9tBJ7ttuImC8kiypE=; b=NQ63R9RaQYriUXwuF6i5Wd5R7lu1P/UG9/0V+M\r
33         X11vmBjS2P85yqFufRhW0w17A5EqN5iBIAB51Fhn9my21sgld2oJxEF0zxRPMxAD\r
34         eLOje9UNHOftAr45i9Lqhfdc/nxYJLXn1CA3zke9xgVz9UZewGOGG+XileIcJGLL\r
35         BKhDM=\r
36 X-Sasl-enc: SiWuNpGwiEpBfwiSr8Y5GBMRs0TtUgDEZ2f/o1WxtUdJ 1364753985\r
37 Received: from localhost (unknown [66.80.90.109])\r
38         by mail.messagingengine.com (Postfix) with ESMTPA id 215452000D3;\r
39         Sun, 31 Mar 2013 14:19:45 -0400 (EDT)\r
40 From: Daniel Bergey <bergey@alum.mit.edu>\r
41 To: Tomi Ollila <tomi.ollila@iki.fi>,\r
42         Notmuch Mail List <notmuch@notmuchmail.org>,\r
43         Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
44 Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB\r
45 In-Reply-To: <m21uccsr3w.fsf@guru.guru-group.fi>\r
46 References: <87lii62sk2.fsf@wonderlust.lan> <87ipa66pne.fsf@betacantrips.com>\r
47         <87ip92zc6m.fsf@wonderlust.lan> <87ip64gdpg.fsf@chladni.lan>\r
48         <m21uccsr3w.fsf@guru.guru-group.fi>\r
49 User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/24.2.1\r
50         (x86_64-pc-linux-gnu)\r
51 Date: Sun, 31 Mar 2013 14:20:15 -0400\r
52 Message-ID: <876207sa74.fsf@chladni.lan>\r
53 MIME-Version: 1.0\r
54 Content-Type: text/plain\r
55 Cc: Chris Thachuk <chris.thachuk@cs.ox.ac.uk>\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Sun, 31 Mar 2013 18:19:50 -0000\r
69 \r
70 >From fbaf5c568876a6f1e3d8c02446bd83331b6325f0 Mon Sep 17 00:00:00 2001\r
71 From: Daniel Bergey <bergey@alum.mit.edu>\r
72 Date: Thu, 26 Jul 2012 15:44:01 -0400\r
73 Subject: [PATCH] emacs: functions to import sender or recipients into BBDB\r
74 \r
75 >From a show buffer, notmuch-bbdb/snarf-from imports the sender into\r
76 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported\r
77 contacts are reported in the minibuffer / Messages buffer.\r
78 \r
79 Both functions use the BBDB parser to recognize email address formats.\r
80 ---\r
81 This differs from the last version of the patch only in whitespace.  In\r
82  addition to changes pointed out by Tomi Ollila, I fixed a ')' on a line\r
83  alone, and aligned the lines of notmuch-bbdb/header-by-name.\r
84 \r
85 I've been using this code (prior to whitespace changes) for a month and\r
86  a half, as far as testing goes.\r
87 \r
88 I wonder if I can get whitespace-mode to warn me about double-spacing....\r
89  emacs/notmuch-address.el |   41 +++++++++++++++++++++++++++++++++++++++++\r
90  1 file changed, 41 insertions(+)\r
91 \r
92 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
93 index 2bf762b..32c8490 100644\r
94 --- a/emacs/notmuch-address.el\r
95 +++ b/emacs/notmuch-address.el\r
96 @@ -96,6 +96,47 @@ line."\r
97  (when (notmuch-address-locate-command notmuch-address-command)\r
98    (notmuch-address-message-insinuate))\r
99  \r
100 +;; functions to add sender / recipients to BBDB\r
101 +\r
102 +(defun notmuch-bbdb/snarf-headers (headers)\r
103 +  ;; Helper function to avoid code duplication in the two below\r
104 +  ;; headers should have the same format as bbdb-get-addresses-headers\r
105 +\r
106 +  ;; bbdb-get-addresses reads these\r
107 +  ;; Ugh, pass-by-global\r
108 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
109 +       (bbdb-get-addresses-headers headers) ; headers to read\r
110 +       (bbdb-gag-messages t)) ; suppress m/n processed message)\r
111 +    (bbdb-update-records addrs t t))\r
112 +\r
113 +  (defun notmuch-bbdb/snarf-from ()\r
114 +    "Import the sender of the current message into BBDB"\r
115 +    (interactive)\r
116 +    (notmuch-bbdb/snarf-headers\r
117 +     (list (assoc 'authors bbdb-get-addresses-headers))))\r
118 +\r
119 +(defun notmuch-bbdb/snarf-to ()\r
120 +  "Import all recipients of the current message into BBDB"\r
121 +  (interactive)\r
122 +  (notmuch-bbdb/snarf-headers\r
123 +   (list (assoc 'recipients bbdb-get-addresses-headers))))\r
124 +\r
125 +(defvar notmuch-bbdb/header-by-name\r
126 +  ;; both are case sensitive\r
127 +  '( ("From" . :From)\r
128 +     ("To" . :To)\r
129 +     ("CC" . :Cc)\r
130 +     ("BCC" . :Bcc)\r
131 +     ("Resent-From" . nil)\r
132 +     ("Reply-To" . nil)\r
133 +     ("Resent-To" . nil)\r
134 +     ("Resent-CC" . nil))\r
135 +  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
136 +from strings as used by bbdb-get-addresses")\r
137 +\r
138 +(defun notmuch-bbdb/get-header-content (name)\r
139 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
140 +\r
141  ;;\r
142  \r
143  (provide 'notmuch-address)\r
144 -- \r
145 1.7.10.4\r
146 \r