Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 25 / 0273b3779e82976b2870f12480e480a927fa2c
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 olra.theworths.org (Postfix) with ESMTP id 3C108421186\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Jan 2012 12:25:36 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.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.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[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 tiULzZBrSQXN for <notmuch@notmuchmail.org>;\r
17         Thu,  5 Jan 2012 12:25:33 -0800 (PST)\r
18 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
19  [74.125.83.53])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
20  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
21  921F742117B    for <notmuch@notmuchmail.org>; Thu,  5 Jan 2012 12:25:30 -0800\r
22  (PST)\r
23 Received: by mail-ee0-f53.google.com with SMTP id d41so756745eek.26\r
24         for <notmuch@notmuchmail.org>; Thu, 05 Jan 2012 12:25:30 -0800 (PST)\r
25 Received: by 10.213.32.76 with SMTP id b12mr716985ebd.6.1325795130164;\r
26         Thu, 05 Jan 2012 12:25:30 -0800 (PST)\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
28         [80.220.92.23])\r
29         by mx.google.com with ESMTPS id 13sm238065664eeu.1.2012.01.05.12.25.28\r
30         (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:25:29 -0800 (PST)\r
31 From: Jani Nikula <jani@nikula.org>\r
32 To: notmuch@notmuchmail.org,\r
33         david@tethera.net\r
34 Subject: [PATCH 3/4] cli: add support for replying just to the sender in\r
35         "notmuch reply"\r
36 Date: Thu,  5 Jan 2012 22:25:14 +0200\r
37 Message-Id:\r
38  <5fd10003b5c515c83cd298ea30f27b01f9233380.1325794371.git.jani@nikula.org>\r
39 X-Mailer: git-send-email 1.7.5.4\r
40 In-Reply-To: <cover.1325794371.git.jani@nikula.org>\r
41 References: <cover.1325794371.git.jani@nikula.org>\r
42 In-Reply-To: <cover.1325794371.git.jani@nikula.org>\r
43 References: <cover.1325794371.git.jani@nikula.org>\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Thu, 05 Jan 2012 20:25:37 -0000\r
57 \r
58 Add new option --no-reply-all to "notmuch reply" to reply just to the\r
59 sender instead of sender and all recipients.\r
60 \r
61 Signed-off-by: Jani Nikula <jani@nikula.org>\r
62 ---\r
63  notmuch-reply.c |   52 ++++++++++++++++++++++++++++++++--------------------\r
64  1 files changed, 32 insertions(+), 20 deletions(-)\r
65 \r
66 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
67 index 000f6da..57458ec 100644\r
68 --- a/notmuch-reply.c\r
69 +++ b/notmuch-reply.c\r
70 @@ -170,7 +170,7 @@ address_is_users (const char *address, notmuch_config_t *config)\r
71  \r
72  /* For each address in 'list' that is not configured as one of the\r
73   * user's addresses in 'config', add that address to 'message' as an\r
74 - * address of 'type'.\r
75 + * address of 'type', if 'add' is true.\r
76   *\r
77   * The first address encountered that *is* the user's address will be\r
78   * returned, (otherwise NULL is returned).\r
79 @@ -179,7 +179,8 @@ static const char *\r
80  add_recipients_for_address_list (GMimeMessage *message,\r
81                                  notmuch_config_t *config,\r
82                                  GMimeRecipientType type,\r
83 -                                InternetAddressList *list)\r
84 +                                InternetAddressList *list,\r
85 +                                notmuch_bool_t add)\r
86  {\r
87      InternetAddress *address;\r
88      int i;\r
89 @@ -197,7 +198,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
90                 continue;\r
91  \r
92             add_recipients_for_address_list (message, config,\r
93 -                                            type, group_list);\r
94 +                                            type, group_list, add);\r
95         } else {\r
96             InternetAddressMailbox *mailbox;\r
97             const char *name;\r
98 @@ -211,7 +212,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
99             if (address_is_users (addr, config)) {\r
100                 if (ret == NULL)\r
101                     ret = addr;\r
102 -           } else {\r
103 +           } else if (add) {\r
104                 g_mime_message_add_recipient (message, type, name, addr);\r
105             }\r
106         }\r
107 @@ -222,7 +223,7 @@ add_recipients_for_address_list (GMimeMessage *message,\r
108  \r
109  /* For each address in 'recipients' that is not configured as one of\r
110   * the user's addresses in 'config', add that address to 'message' as\r
111 - * an address of 'type'.\r
112 + * an address of 'type', if 'add' is true.\r
113   *\r
114   * The first address encountered that *is* the user's address will be\r
115   * returned, (otherwise NULL is returned).\r
116 @@ -231,7 +232,8 @@ static const char *\r
117  add_recipients_for_string (GMimeMessage *message,\r
118                            notmuch_config_t *config,\r
119                            GMimeRecipientType type,\r
120 -                          const char *recipients)\r
121 +                          const char *recipients,\r
122 +                          notmuch_bool_t add)\r
123  {\r
124      InternetAddressList *list;\r
125  \r
126 @@ -242,7 +244,7 @@ add_recipients_for_string (GMimeMessage *message,\r
127      if (list == NULL)\r
128         return NULL;\r
129  \r
130 -    return add_recipients_for_address_list (message, config, type, list);\r
131 +    return add_recipients_for_address_list (message, config, type, list, add);\r
132  }\r
133  \r
134  /* Does the address in the Reply-To header of 'message' already appear\r
135 @@ -284,7 +286,9 @@ reply_to_header_is_redundant (notmuch_message_t *message)\r
136      return 0;\r
137  }\r
138  \r
139 -/* Augments the recipients of reply from the headers of message.\r
140 +/* Augments the recipients of reply from the headers of message. If 'reply_all'\r
141 + * is true, use sender and all recipients, otherwise use just the sender\r
142 + * ("reply-to" or "from" headers).\r
143   *\r
144   * If any of the user's addresses were found in these headers, the first\r
145   * of these returned, otherwise NULL is returned.\r
146 @@ -292,17 +296,19 @@ reply_to_header_is_redundant (notmuch_message_t *message)\r
147  static const char *\r
148  add_recipients_from_message (GMimeMessage *reply,\r
149                              notmuch_config_t *config,\r
150 -                            notmuch_message_t *message)\r
151 +                            notmuch_message_t *message,\r
152 +                            notmuch_bool_t reply_all)\r
153  {\r
154      struct {\r
155         const char *header;\r
156         const char *fallback;\r
157         GMimeRecipientType recipient_type;\r
158 +       notmuch_bool_t always; /* use entry when not reply_all */\r
159      } reply_to_map[] = {\r
160 -       { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO  },\r
161 -       { "to",         NULL, GMIME_RECIPIENT_TYPE_TO  },\r
162 -       { "cc",         NULL, GMIME_RECIPIENT_TYPE_CC  },\r
163 -       { "bcc",        NULL, GMIME_RECIPIENT_TYPE_BCC }\r
164 +       { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO,  TRUE },\r
165 +       { "to",         NULL, GMIME_RECIPIENT_TYPE_TO,  FALSE },\r
166 +       { "cc",         NULL, GMIME_RECIPIENT_TYPE_CC,  FALSE },\r
167 +       { "bcc",        NULL, GMIME_RECIPIENT_TYPE_BCC, FALSE }\r
168      };\r
169      const char *from_addr = NULL;\r
170      unsigned int i;\r
171 @@ -334,7 +340,8 @@ add_recipients_from_message (GMimeMessage *reply,\r
172  \r
173         addr = add_recipients_for_string (reply, config,\r
174                                           reply_to_map[i].recipient_type,\r
175 -                                         recipients);\r
176 +                                         recipients,\r
177 +                                         reply_all || reply_to_map[i].always);\r
178         if (from_addr == NULL)\r
179             from_addr = addr;\r
180      }\r
181 @@ -480,7 +487,8 @@ static int\r
182  notmuch_reply_format_default(void *ctx,\r
183                              notmuch_config_t *config,\r
184                              notmuch_query_t *query,\r
185 -                            notmuch_show_params_t *params)\r
186 +                            notmuch_show_params_t *params,\r
187 +                            notmuch_bool_t reply_all)\r
188  {\r
189      GMimeMessage *reply;\r
190      notmuch_messages_t *messages;\r
191 @@ -509,7 +517,8 @@ notmuch_reply_format_default(void *ctx,\r
192             g_mime_message_set_subject (reply, subject);\r
193         }\r
194  \r
195 -       from_addr = add_recipients_from_message (reply, config, message);\r
196 +       from_addr = add_recipients_from_message (reply, config, message,\r
197 +                                                reply_all);\r
198  \r
199         if (from_addr == NULL)\r
200             from_addr = guess_from_received_header (config, message);\r
201 @@ -558,7 +567,8 @@ static int\r
202  notmuch_reply_format_headers_only(void *ctx,\r
203                                   notmuch_config_t *config,\r
204                                   notmuch_query_t *query,\r
205 -                                 unused (notmuch_show_params_t *params))\r
206 +                                 unused (notmuch_show_params_t *params),\r
207 +                                 notmuch_bool_t reply_all)\r
208  {\r
209      GMimeMessage *reply;\r
210      notmuch_messages_t *messages;\r
211 @@ -598,7 +608,7 @@ notmuch_reply_format_headers_only(void *ctx,\r
212         g_mime_object_set_header (GMIME_OBJECT (reply),\r
213                                   "References", references);\r
214  \r
215 -       (void)add_recipients_from_message (reply, config, message);\r
216 +       (void)add_recipients_from_message (reply, config, message, reply_all);\r
217  \r
218         reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));\r
219         printf ("%s", reply_headers);\r
220 @@ -625,10 +635,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
221      notmuch_query_t *query;\r
222      char *query_string;\r
223      int opt_index, ret = 0;\r
224 -    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params);\r
225 +    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all);\r
226      notmuch_show_params_t params = { .part = -1 };\r
227      int format = FORMAT_DEFAULT;\r
228      notmuch_bool_t decrypt = FALSE;\r
229 +    notmuch_bool_t no_reply_all = FALSE;\r
230  \r
231      notmuch_opt_desc_t options[] = {\r
232         { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
233 @@ -636,6 +647,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
234                                   { "headers-only", FORMAT_HEADERS_ONLY },\r
235                                   { 0, 0 } } },\r
236         { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
237 +       { NOTMUCH_OPT_BOOLEAN, &no_reply_all, "no-reply-all", 'r', 0 },\r
238         { 0, 0, 0, 0, 0 }\r
239      };\r
240  \r
241 @@ -688,7 +700,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
242         return 1;\r
243      }\r
244  \r
245 -    if (reply_format_func (ctx, config, query, &params) != 0)\r
246 +    if (reply_format_func (ctx, config, query, &params, !no_reply_all) != 0)\r
247         return 1;\r
248  \r
249      notmuch_query_destroy (query);\r
250 -- \r
251 1.7.5.4\r
252 \r