Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 8d / 2c2ffa950015b920d34c092f40d1897c822796
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 CA3A8431FBD\r
6         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 12:44:33 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 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=1, 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 ErtsBMtWHQDC for <notmuch@notmuchmail.org>;\r
18         Sat,  4 Feb 2012 12:44:32 -0800 (PST)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id C9CF6431FC4\r
23         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 12:44:31 -0800 (PST)\r
24 Received: by werb10 with SMTP id b10so4024656wer.26\r
25         for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 12:44:30 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=tHqp/y/ke/09cnIWldd9x5kTfRMd4pkPtT9WlXCfRP0=;\r
29         b=EP4WIL8MeypiuqjWBb4YsNngBjgOvLOspXMsOCX8+gYvAfJiNqiiDjplL4BWybCc3y\r
30         WXPQs0WvHdHAzsJEXRNDR/VxYUogdk0jg3R4Ezy9kbePVp6mL7u+LL+mc04RUok6uAjQ\r
31         e6qkfjYMkgkaaLnVlvmt9RARRW5SjdQOLkGGU=\r
32 Received: by 10.216.132.148 with SMTP id o20mr1132792wei.33.1328388270696;\r
33         Sat, 04 Feb 2012 12:44:30 -0800 (PST)\r
34 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
35  [94.192.233.223])      by mx.google.com with ESMTPS id\r
36  y1sm30164139wiw.6.2012.02.04.12.44.29  (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Sat, 04 Feb 2012 12:44:30 -0800 (PST)\r
38 From: Mark Walters <markwalters1009@gmail.com>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 1/4] cli: add --from option to reply to restrict guessing\r
41         of the From: header.\r
42 Date: Sat,  4 Feb 2012 20:45:14 +0000\r
43 Message-Id: <1328388317-20161-2-git-send-email-markwalters1009@gmail.com>\r
44 X-Mailer: git-send-email 1.7.2.3\r
45 In-Reply-To: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com>\r
46 References: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Sat, 04 Feb 2012 20:44:34 -0000\r
60 \r
61 Add an option --from= to notmuch-reply.c to restrict guessing of the\r
62 From: header. The existing logic looks as the main headers, then at\r
63 the delivery headers, and finally defaults to the config file address.\r
64 \r
65 This patch allows the user to restrict which of these guesses are\r
66 made.  Currently the supported values are:\r
67        default|fallback-all    current behaviour\r
68        fallback-received       fallback to delivery headers but not config file\r
69        fallback-none           only look at from/reply-to/to/cc/ headers\r
70        none                    From: header is always left empty\r
71 \r
72 If the code does not find an allowed address it outputs an empty From:\r
73 line and the caller can decide how to respond.\r
74 ---\r
75  notmuch-reply.c |   45 ++++++++++++++++++++++++++++++++++++---------\r
76  1 files changed, 36 insertions(+), 9 deletions(-)\r
77 \r
78 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
79 index f55b1d2..8c73cb7 100644\r
80 --- a/notmuch-reply.c\r
81 +++ b/notmuch-reply.c\r
82 @@ -24,6 +24,15 @@\r
83  #include "gmime-filter-reply.h"\r
84  #include "gmime-filter-headers.h"\r
85  \r
86 +/* The order here matters as we use '<' when deciding how to behave. */\r
87 +enum {\r
88 +    FROM_FALLBACK_ALL,\r
89 +    FROM_FALLBACK_RECEIVED,\r
90 +    FROM_FALLBACK_NONE,\r
91 +    FROM_NONE,\r
92 +    FROM_PRIMARY\r
93 +};\r
94 +\r
95  static void\r
96  reply_headers_message_part (GMimeMessage *message);\r
97  \r
98 @@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,\r
99                              notmuch_config_t *config,\r
100                              notmuch_query_t *query,\r
101                              notmuch_show_params_t *params,\r
102 -                            notmuch_bool_t reply_all)\r
103 +                            notmuch_bool_t reply_all,\r
104 +                            int from_select)\r
105  {\r
106      GMimeMessage *reply;\r
107      notmuch_messages_t *messages;\r
108 @@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,\r
109         from_addr = add_recipients_from_message (reply, config, message,\r
110                                                  reply_all);\r
111  \r
112 -       if (from_addr == NULL)\r
113 +       if (from_addr == NULL && from_select <= FROM_FALLBACK_RECEIVED)\r
114             from_addr = guess_from_received_header (config, message);\r
115  \r
116 -       if (from_addr == NULL)\r
117 +       if ((from_addr == NULL && from_select <= FROM_FALLBACK_ALL) ||\r
118 +           from_select == FROM_PRIMARY)\r
119             from_addr = notmuch_config_get_user_primary_email (config);\r
120  \r
121 -       from_addr = talloc_asprintf (ctx, "%s <%s>",\r
122 -                                    notmuch_config_get_user_name (config),\r
123 -                                    from_addr);\r
124 +       /* If we have an address and we want an address print\r
125 +        * it. Otherwise set an empty From: header. */\r
126 +       if (from_addr != NULL && from_select != FROM_NONE) {\r
127 +           from_addr = talloc_asprintf (ctx, "%s <%s>",\r
128 +                                        notmuch_config_get_user_name (config),\r
129 +                                        from_addr);\r
130 +       } else {\r
131 +           from_addr = talloc_strdup (ctx, "");\r
132 +       }\r
133         g_mime_object_set_header (GMIME_OBJECT (reply),\r
134                                   "From", from_addr);\r
135  \r
136 @@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
137                                   notmuch_config_t *config,\r
138                                   notmuch_query_t *query,\r
139                                   unused (notmuch_show_params_t *params),\r
140 -                                 notmuch_bool_t reply_all)\r
141 +                                 notmuch_bool_t reply_all,\r
142 +                                 unused (int from_select))\r
143  {\r
144      GMimeMessage *reply;\r
145      notmuch_messages_t *messages;\r
146 @@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
147      notmuch_query_t *query;\r
148      char *query_string;\r
149      int opt_index, ret = 0;\r
150 -    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
151 +    int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t reply_all, int from_select);\r
152      notmuch_show_params_t params = { .part = -1 };\r
153      int format = FORMAT_DEFAULT;\r
154      int reply_all = TRUE;\r
155 +    int from_select = FROM_FALLBACK_ALL;\r
156      notmuch_bool_t decrypt = FALSE;\r
157  \r
158      notmuch_opt_desc_t options[] = {\r
159 @@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
160           (notmuch_keyword_t []){ { "all", TRUE },\r
161                                   { "sender", FALSE },\r
162                                   { 0, 0 } } },\r
163 +       { NOTMUCH_OPT_KEYWORD, &from_select, "from", 'F',\r
164 +         (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },\r
165 +                                 { "fallback-all", FROM_FALLBACK_ALL },\r
166 +                                 { "fallback-received", FROM_FALLBACK_RECEIVED },\r
167 +                                 { "fallback-none", FROM_FALLBACK_NONE },\r
168 +                                 { "none", FROM_NONE },\r
169 +                                 { "primary", FROM_PRIMARY },\r
170 +                                 { 0, 0 } } },\r
171         { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
172         { 0, 0, 0, 0, 0 }\r
173      };\r
174 @@ -732,7 +759,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
175         return 1;\r
176      }\r
177  \r
178 -    if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
179 +    if (reply_format_func (ctx, config, query, &params, reply_all, from_select) != 0)\r
180         return 1;\r
181  \r
182      notmuch_query_destroy (query);\r
183 -- \r
184 1.7.2.3\r
185 \r