Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / dd / dd03ecd9e4cf7945dbd54cd1662753b0e58fc4
1 Return-Path: <markwalters1009@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 AA081431FB6\r
6         for <notmuch@notmuchmail.org>; Thu, 26 May 2011 09:07:31 -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: 1.424\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.424 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=2.223, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id z3NHIwoxOplR for <notmuch@notmuchmail.org>;\r
18         Thu, 26 May 2011 09:07:28 -0700 (PDT)\r
19 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
20  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  50C1C429E2A    for <notmuch@notmuchmail.org>; Thu, 26 May 2011 09:07:26 -0700\r
23  (PDT)\r
24 Received: by mail-ww0-f45.google.com with SMTP id 36so763098wwi.2\r
25         for <notmuch@notmuchmail.org>; Thu, 26 May 2011 09:07:26 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
27         h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer\r
28         :in-reply-to:references;\r
29         bh=fQ7CC6qEwJqhYeDPrVlCP/zdfjHxhHrlxv12SNHvVEY=;\r
30         b=TWf0hEqp5V5ecw0ibH27zV0jolte7tCsdZzYyXB7Oogo7VX91hBEeBZ/blx819hzx2\r
31         O5maz37ipNGXWLoQ80xEG5G+PV4tfZ8GWIQ+3kgKhK+8Ufrxs65squ3gaGptjLjBlWxM\r
32         EH5F4P2IYB7mSR9jF7QGnMWiOrUXNJRv7OQDg=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
34         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
35         b=MfWWxjFCCoYcWX2RXwhvv4MPiM+FLOHVNHQkAXOaE24HSfLBNyQKK3hwmOHOvyY5tr\r
36         DKxO+vjj90cxRD51cAwX2xeKHdaZV3q2rDaCU7pIngKePvrGrct6tBGsAVY1MsS3yYws\r
37         e/ng6U+k7wmLuftvMV+oZc9fGBddwGRGt19VI=\r
38 Received: by 10.216.54.134 with SMTP id i6mr971773wec.75.1306426045910;\r
39         Thu, 26 May 2011 09:07:25 -0700 (PDT)\r
40 Received: from localhost.localdomain (93-97-25-209.zone5.bethere.co.uk\r
41         [93.97.25.209])\r
42         by mx.google.com with ESMTPS id k70sm457497weq.6.2011.05.26.09.07.24\r
43         (version=TLSv1/SSLv3 cipher=OTHER);\r
44         Thu, 26 May 2011 09:07:25 -0700 (PDT)\r
45 From: Mark Walters <markwalters1009@gmail.com>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH 1/2] Command line changes for reply-to-sender\r
48 Date: Thu, 26 May 2011 17:06:51 +0100\r
49 Message-Id: <1306426012-8176-2-git-send-email-markwalters1009@gmail.com>\r
50 X-Mailer: git-send-email 1.7.2.5\r
51 In-Reply-To: <1306426012-8176-1-git-send-email-markwalters1009@gmail.com>\r
52 References: <1306426012-8176-1-git-send-email-markwalters1009@gmail.com>\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Thu, 26 May 2011 16:07:31 -0000\r
66 \r
67 Adds the format "--format=one" to possible reply formats which only\r
68 replies to the sender.\r
69 \r
70 More precisely the function follows these rules:\r
71 reply only to sender unless it was the user\r
72 reply only to all people on the to line unless they were all the user\r
73 reply to all people on the cc line\r
74 \r
75 The most common expected case is we just reply to sender, but if we reply to\r
76 our own email then we reply to the whole to line.\r
77 \r
78 Implementation details\r
79 \r
80 Note we continue parsing addresses beyond the ones we reply to because\r
81 we want to make sure the from address is correct. (At the very least it\r
82 is the same as it would be if we replied to all.)\r
83 \r
84 We overload the message variable in add_recipients_for_address_list so\r
85 if it is NULL we parse the address (looking for the users address)\r
86 but do not add to the message recipients list\r
87 \r
88 We add the variable reply_to_all to the function chain to keep track\r
89 of whether we should reply to everyone.\r
90 ---\r
91  notmuch-reply.c |   38 +++++++++++++++++++++++++++-----------\r
92  1 files changed, 27 insertions(+), 11 deletions(-)\r
93 \r
94 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
95 index ab15650..3df3b52 100644\r
96 --- a/notmuch-reply.c\r
97 +++ b/notmuch-reply.c\r
98 @@ -191,7 +191,8 @@ add_recipients_for_address_list (GMimeMessage *message,\r
99                 if (ret == NULL)\r
100                     ret = addr;\r
101             } else {\r
102 -               g_mime_message_add_recipient (message, type, name, addr);\r
103 +                if (message) \r
104 +                     g_mime_message_add_recipient (message, type, name, addr);\r
105             }\r
106         }\r
107      }\r
108 @@ -271,7 +272,8 @@ reply_to_header_is_redundant (notmuch_message_t *message)\r
109  static const char *\r
110  add_recipients_from_message (GMimeMessage *reply,\r
111                              notmuch_config_t *config,\r
112 -                            notmuch_message_t *message)\r
113 +                            notmuch_message_t *message,\r
114 +                            int reply_to_all)\r
115  {\r
116      struct {\r
117         const char *header;\r
118 @@ -311,9 +313,20 @@ add_recipients_from_message (GMimeMessage *reply,\r
119             recipients = notmuch_message_get_header (message,\r
120                                                      reply_to_map[i].fallback);\r
121  \r
122 -       addr = add_recipients_for_string (reply, config,\r
123 -                                         reply_to_map[i].recipient_type,\r
124 -                                         recipients);\r
125 +\r
126 +       /* We add the addresses if we are replying to all or we have not yet found\r
127 +        * a non-user address. We have to keep parsing to make sure we do find the \r
128 +        * correct from address for the user, but we pass a NULL message\r
129 +        */\r
130 +       if ((reply_to_all) || (g_mime_message_get_all_recipients (reply) == NULL))\r
131 +           addr = add_recipients_for_string (reply, config,\r
132 +                                             reply_to_map[i].recipient_type,\r
133 +                                             recipients);\r
134 +       else\r
135 +            addr = add_recipients_for_string (NULL, config,\r
136 +                                              reply_to_map[i].recipient_type,\r
137 +                                              recipients);\r
138 +\r
139         if (from_addr == NULL)\r
140             from_addr = addr;\r
141      }\r
142 @@ -453,7 +466,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message\r
143  }\r
144  \r
145  static int\r
146 -notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
147 +notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)\r
148  {\r
149      GMimeMessage *reply;\r
150      notmuch_messages_t *messages;\r
151 @@ -484,7 +497,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_\r
152             g_mime_message_set_subject (reply, subject);\r
153         }\r
154  \r
155 -       from_addr = add_recipients_from_message (reply, config, message);\r
156 +       from_addr = add_recipients_from_message (reply, config, message, reply_to_all);\r
157  \r
158         if (from_addr == NULL)\r
159             from_addr = guess_from_received_header (config, message);\r
160 @@ -531,7 +544,7 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_\r
161  \r
162  /* This format is currently tuned for a git send-email --notmuch hook */\r
163  static int\r
164 -notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query)\r
165 +notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all)\r
166  {\r
167      GMimeMessage *reply;\r
168      notmuch_messages_t *messages;\r
169 @@ -571,7 +584,7 @@ notmuch_reply_format_headers_only(void *ctx, notmuch_config_t *config, notmuch_q\r
170         g_mime_object_set_header (GMIME_OBJECT (reply),\r
171                                   "References", references);\r
172  \r
173 -       (void)add_recipients_from_message (reply, config, message);\r
174 +       (void)add_recipients_from_message (reply, config, message, reply_to_all);\r
175  \r
176         reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));\r
177         printf ("%s", reply_headers);\r
178 @@ -593,7 +606,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
179      notmuch_query_t *query;\r
180      char *opt, *query_string;\r
181      int i, ret = 0;\r
182 -    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query);\r
183 +    int reply_to_all = 1;\r
184 +    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, int reply_to_all);\r
185  \r
186      reply_format_func = notmuch_reply_format_default;\r
187  \r
188 @@ -608,6 +622,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
189                 reply_format_func = notmuch_reply_format_default;\r
190             } else if (strcmp (opt, "headers-only") == 0) {\r
191                 reply_format_func = notmuch_reply_format_headers_only;\r
192 +           } else if (strcmp (opt, "one") == 0) {\r
193 +               reply_to_all = 0;\r
194             } else {\r
195                 fprintf (stderr, "Invalid value for --format: %s\n", opt);\r
196                 return 1;\r
197 @@ -647,7 +663,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
198         return 1;\r
199      }\r
200  \r
201 -    if (reply_format_func (ctx, config, query) != 0)\r
202 +    if (reply_format_func (ctx, config, query, reply_to_all) != 0)\r
203         return 1;\r
204  \r
205      notmuch_query_destroy (query);\r
206 -- \r
207 1.7.2.5\r
208 \r