Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 58 / 1e91409e173b347cf6fc16f0ca35ac178233b2
1 Return-Path: <jani@nikula.org>\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 arlo.cworth.org (Postfix) with ESMTP id 09CD56DE092A\r
6  for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:25 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: 0.505\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=0.505 tagged_above=-999 required=5 tests=[AWL=1.225, \r
13  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id 8HV_uJGfYNBP for <notmuch@notmuchmail.org>;\r
18  Sat, 18 Jun 2016 14:33:17 -0700 (PDT)\r
19 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
20  [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 3D6BE6DE028C for\r
21  <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:05 -0700 (PDT)\r
22 Received: by mail-wm0-f68.google.com with SMTP id r201so5510009wme.0\r
23  for <notmuch@notmuchmail.org>; Sat, 18 Jun 2016 14:33:05 -0700 (PDT)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25  d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references\r
27  :in-reply-to:references;\r
28  bh=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=;\r
29  b=TuT63OI69vQWCgyoYinWpBLsWhLPf89uKOBeP0/497r7W/8SGwkpezKJZg+o6d09tY\r
30  o1x1JFB3UcEsLRt5KEYTqLyY/ozgffjSTldK5Xw9XMvKs+IB8saI/PTeMO+XlO3cjq1B\r
31  WAwVRudJp4A1lTM6eJUSff62hhfY/Rl1mZGA3ki3fqUzLmiZrWrbCo5k/e5QkUT8BKLY\r
32  IMylLqjzM/+O0QDhjfimP1LYdWdl5bzwQcZ7a2GWFZF9S2KcTv3uzxm8QvtmsOt/6Phm\r
33  hiZpIAJRgMWhA0AS8wwSE9r+F9m1a2iOenEU9FSe2QugWOB8AzbmRgUYndJ0Lc0n+LR9\r
34  +kSA==\r
35 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
36  d=1e100.net; s=20130820;\r
37  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
38  :references:in-reply-to:references;\r
39  bh=fbeShvw4M66SrxkIEgtBhkFxVPPUGacbY8QcRCVt1P8=;\r
40  b=eXJX2QJbSYdentWTtakc5lE3Z98ONp95alzqJ3MoP5s4zxUfpDbnkTJETe5E5H6B75\r
41  ZHddAbBE7izwLiDXlwcnP/X6dSf1z5pT2Yweqo+788Bu5Vrx6GbomS4ea4I9SeAJtNYG\r
42  4x4PTOFx/wjJZxEAcHZPqMB2O+zXKO6l+Tyt8/NEvGzNJE5Vtl70s69l5CXy6eHqF7bO\r
43  NGHTxinpnmeKfuKzFNipWPkPCC2+uEasCTMPdGVaQigx9gVluT/WEzzggyC3EwmmGmaq\r
44  kpxcbIc4DPodITRqPSO0yLLlHvBs4rbkwNwBtbGTIreRyO4bl9fYs110uYTSJHQGuaqn\r
45  EAhg==\r
46 X-Gm-Message-State:\r
47  ALyK8tLGDtwiFEGvyotgCsNzh+OIOxRZkfCBcC0/IgGlH/RrRWHe3qg68rE61sYrsZZ7hA==\r
48 X-Received: by 10.28.26.4 with SMTP id a4mr4124855wma.92.1466285583959;\r
49  Sat, 18 Jun 2016 14:33:03 -0700 (PDT)\r
50 Received: from localhost (dsl-hkibrasgw2-58c37a-44.dhcp.inet.fi.\r
51  [88.195.122.44])\r
52  by smtp.gmail.com with ESMTPSA id r130sm1676834wmf.20.2016.06.18.14.33.03\r
53  (version=TLSv1/SSLv3 cipher=OTHER);\r
54  Sat, 18 Jun 2016 14:33:03 -0700 (PDT)\r
55 From: Jani Nikula <jani@nikula.org>\r
56 To: notmuch@notmuchmail.org\r
57 Cc: jani@nikula.org,\r
58         Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
59 Subject: [PATCH 4/7] cli/reply: reorganize create_reply_message()\r
60 Date: Sun, 19 Jun 2016 00:31:30 +0300\r
61 Message-Id:\r
62  <50d4410b1d865fbf1618febfae2f54c5173243ae.1466284726.git.jani@nikula.org>\r
63 X-Mailer: git-send-email 2.1.4\r
64 In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
65 References: <cover.1466284726.git.jani@nikula.org>\r
66 In-Reply-To: <cover.1466284726.git.jani@nikula.org>\r
67 References: <cover.1466284726.git.jani@nikula.org>\r
68 X-BeenThere: notmuch@notmuchmail.org\r
69 X-Mailman-Version: 2.1.20\r
70 Precedence: list\r
71 List-Id: "Use and development of the notmuch mail system."\r
72  <notmuch.notmuchmail.org>\r
73 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
74  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
75 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
76 List-Post: <mailto:notmuch@notmuchmail.org>\r
77 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
78 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
79  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
80 X-List-Received-Date: Sat, 18 Jun 2016 21:33:25 -0000\r
81 \r
82 Again, in preparation for later unification, reorganize\r
83 create_reply_message() to be more similar to the open coded version in\r
84 the headers-only format reply code. Due to "pretty" header ordering,\r
85 there should be no change in output. There should be no functional\r
86 changes.\r
87 ---\r
88  notmuch-reply.c | 45 +++++++++++++++++++++------------------------\r
89  1 file changed, 21 insertions(+), 24 deletions(-)\r
90 \r
91 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
92 index 4b97ffa4f096..eb07405591fd 100644\r
93 --- a/notmuch-reply.c\r
94 +++ b/notmuch-reply.c\r
95 @@ -532,12 +532,20 @@ create_reply_message(void *ctx,\r
96         return NULL;\r
97      }\r
98  \r
99 -    subject = notmuch_message_get_header (message, "subject");\r
100 -    if (subject) {\r
101 -       if (strncasecmp (subject, "Re:", 3))\r
102 -           subject = talloc_asprintf (ctx, "Re: %s", subject);\r
103 -       g_mime_message_set_subject (reply, subject);\r
104 -    }\r
105 +    in_reply_to = talloc_asprintf (ctx, "<%s>",\r
106 +                                  notmuch_message_get_message_id (message));\r
107 +\r
108 +    g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to);\r
109 +\r
110 +    orig_references = notmuch_message_get_header (message, "references");\r
111 +    if (!orig_references)\r
112 +       /* Treat errors like missing References headers. */\r
113 +       orig_references = "";\r
114 +    references = talloc_asprintf (ctx, "%s%s%s",\r
115 +                                 *orig_references ? orig_references : "",\r
116 +                                 *orig_references ? " " : "",\r
117 +                                 in_reply_to);\r
118 +    g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);\r
119  \r
120      from_addr = add_recipients_from_message (reply, config,\r
121                                              message, reply_all);\r
122 @@ -572,25 +580,14 @@ create_reply_message(void *ctx,\r
123      from_addr = talloc_asprintf (ctx, "%s <%s>",\r
124                                  notmuch_config_get_user_name (config),\r
125                                  from_addr);\r
126 -    g_mime_object_set_header (GMIME_OBJECT (reply),\r
127 -                             "From", from_addr);\r
128 -\r
129 -    in_reply_to = talloc_asprintf (ctx, "<%s>",\r
130 -                                  notmuch_message_get_message_id (message));\r
131 -\r
132 -    g_mime_object_set_header (GMIME_OBJECT (reply),\r
133 -                             "In-Reply-To", in_reply_to);\r
134 +    g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr);\r
135  \r
136 -    orig_references = notmuch_message_get_header (message, "references");\r
137 -    if (!orig_references)\r
138 -       /* Treat errors like missing References headers. */\r
139 -       orig_references = "";\r
140 -    references = talloc_asprintf (ctx, "%s%s%s",\r
141 -                                 *orig_references ? orig_references : "",\r
142 -                                 *orig_references ? " " : "",\r
143 -                                 in_reply_to);\r
144 -    g_mime_object_set_header (GMIME_OBJECT (reply),\r
145 -                             "References", references);\r
146 +    subject = notmuch_message_get_header (message, "subject");\r
147 +    if (subject) {\r
148 +       if (strncasecmp (subject, "Re:", 3))\r
149 +           subject = talloc_asprintf (ctx, "Re: %s", subject);\r
150 +       g_mime_message_set_subject (reply, subject);\r
151 +    }\r
152  \r
153      return reply;\r
154  }\r
155 -- \r
156 2.1.4\r
157 \r