Missing headers when forwarding html message as RFC822
[notmuch-archives.git] / 5d / 9ce433a929eaead1d2d00634f64ad45d81843f
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 A5F56414BA9\r
6         for <notmuch@notmuchmail.org>; Thu,  7 Feb 2013 10:51:08 -0800 (PST)\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 xxMOZUDuhkob for <notmuch@notmuchmail.org>;\r
17         Thu,  7 Feb 2013 10:51:04 -0800 (PST)\r
18 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com\r
19         [66.111.4.29])\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 8A3D0416456\r
23         for <notmuch@notmuchmail.org>; Thu,  7 Feb 2013 10:51:04 -0800 (PST)\r
24 Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41])\r
25         by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 520F220B2E;\r
26         Thu,  7 Feb 2013 13:51:02 -0500 (EST)\r
27 Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161])\r
28         by compute1.internal (MEProxy); Thu, 07 Feb 2013 13:51:02 -0500\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=EkGqWn\r
32         yZXJIr5/hdX46yeRz4Jyk=; b=PszpgNbhDlXhUgm/PWO9JVFp1Wi9Yy0jECLQ5N\r
33         SuJwoyL6UGgc2l1wxX33H8kgjDNvYZwVQgM59sFOx7IAkL8eFlAytRy12/nVf+Vl\r
34         lWQLS3J+Z5V0iX0R852E6j0sFXFeWn1uzVfuE9u4vW2/cb7rdMBHwaBGTk7ewPPD\r
35         Gf7Xc=\r
36 X-Sasl-enc: 5QLE9Cq8hPMhBKKjvWMixHDczAheWytLPMAVHLdKsRM/ 1360263062\r
37 Received: from localhost (unknown [66.80.90.109])\r
38         by mail.messagingengine.com (Postfix) with ESMTPA id F2AED4827DE;\r
39         Thu,  7 Feb 2013 13:51:01 -0500 (EST)\r
40 From: Daniel Bergey <bergey@alum.mit.edu>\r
41 To: Notmuch Mail List <notmuch@notmuchmail.org>,\r
42         Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
43 Subject: Re: [PATCH] emacs: functions to import sender or recipient into BBDB\r
44 In-Reply-To: <87ip92zc6m.fsf@wonderlust.lan>\r
45 References: <87lii62sk2.fsf@wonderlust.lan> <87ipa66pne.fsf@betacantrips.com>\r
46         <87ip92zc6m.fsf@wonderlust.lan>\r
47 User-Agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/24.2.1\r
48         (x86_64-pc-linux-gnu)\r
49 Date: Thu, 07 Feb 2013 13:51:07 -0500\r
50 Message-ID: <87ip64gdpg.fsf@chladni.lan>\r
51 MIME-Version: 1.0\r
52 Content-Type: text/plain\r
53 Cc: Chris Thachuk <chris.thachuk@cs.ox.ac.uk>\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Thu, 07 Feb 2013 18:51:08 -0000\r
67 \r
68 >From a show buffer, notmuch-bbdb/snarf-from imports the sender into\r
69 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported\r
70 concacts are reported in the minibuffer / Messages buffer.\r
71 \r
72 Both functions use the BBDB parser to recognize email address formats.\r
73 ---\r
74 Following discussion upthread, I put everything in notmuch-address.  I\r
75 renamed the functions to put notmuch before bbdb.  And I replaced the\r
76 horrid comma-splitting from my first version with the functions BBDB\r
77 provides for parsing email headers.\r
78 \r
79 It looks as though Reply-To is not exposed in the :headers plist.  I\r
80 assume the Resent-* headers are not, either.  Therefore none of these\r
81 are imported (nil entries in notmuch-bbdb/header-by-name).  They would be\r
82 easy to add if the plist is expanded.\r
83 \r
84 Thanks, and sorry it's taken me so long to get back to this patch.\r
85 \r
86  emacs/notmuch-address.el |   43 +++++++++++++++++++++++++++++++++++++++++++\r
87  1 file changed, 43 insertions(+)\r
88 \r
89 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
90 index 2bf762b..8d5f727 100644\r
91 --- a/emacs/notmuch-address.el\r
92 +++ b/emacs/notmuch-address.el\r
93 @@ -98,4 +98,47 @@ line."\r
94  \r
95  ;;\r
96  \r
97 +;; functions to add sender / recipients to BBDB\r
98 +\r
99 +(defun notmuch-bbdb/snarf-headers (headers)\r
100 +  ;; Helper function to avoid code duplication in the two below\r
101 +  ;; headers should have the same format as bbdb-get-addresses-headers\r
102 +\r
103 +  ;; bbdb-get-addresses reads these\r
104 +  ;; Ugh, pass-by-global\r
105 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
106 +        (bbdb-get-addresses-headers headers) ; headers to read\r
107 +        (bbdb-gag-messages t) ; suppress m/n processed message\r
108 +        )\r
109 +    (bbdb-update-records addrs t t)))\r
110 +\r
111 +(defun notmuch-bbdb/snarf-from ()\r
112 +  "Import the sender of the current message into BBDB"\r
113 +  (interactive)\r
114 +  (notmuch-bbdb/snarf-headers\r
115 +   (list  (assoc 'authors bbdb-get-addresses-headers))))\r
116 +\r
117 +(defun notmuch-bbdb/snarf-to ()\r
118 +  "Import all recipients of the current message into BBDB"\r
119 +  (interactive)\r
120 +  (notmuch-bbdb/snarf-headers\r
121 +   (list  (assoc 'recipients bbdb-get-addresses-headers))))\r
122 +\r
123 +(defvar notmuch-bbdb/header-by-name\r
124 +  ;; both are case sensitive\r
125 +  '( ("From" . :From)\r
126 +       ("To" . :To)\r
127 +       ("CC" . :Cc)\r
128 +       ("BCC" . :Bcc)\r
129 +       ("Resent-From" . nil)\r
130 +       ("Reply-To" . nil)\r
131 +       ("Resent-To" . nil)\r
132 +       ("Resent-CC" . nil))\r
133 +  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
134 +from strings as used by bbdb-get-addresses")\r
135 +\r
136 +(defun notmuch-bbdb/get-header-content (name)\r
137 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
138 +\r
139 +\r
140  (provide 'notmuch-address)\r
141 -- \r
142 1.7.10.4\r
143 \r