Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 35 / abbef1d4b0d3287ec7985b9c48c2e22f722477
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 49795431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 14:07:49 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id D23wS5OJWsIa for <notmuch@notmuchmail.org>;\r
16         Sat,  4 Feb 2012 14:07:48 -0800 (PST)\r
17 Received: from mail-lpp01m020-f181.google.com (mail-lpp01m020-f181.google.com\r
18         [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 42E5D431FAE\r
21         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 14:07:48 -0800 (PST)\r
22 Received: by lbbgn5 with SMTP id gn5so1149794lbb.26\r
23         for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 14:07:45 -0800 (PST)\r
24 Received: by 10.112.98.37 with SMTP id ef5mr3336137lbb.73.1328393265450;\r
25         Sat, 04 Feb 2012 14:07:45 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
27         [84.248.80.253])\r
28         by mx.google.com with ESMTPS id f2sm8577276lbw.5.2012.02.04.14.07.43\r
29         (version=SSLv3 cipher=OTHER); Sat, 04 Feb 2012 14:07:44 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH v2 1/4] cli: add --from option to reply to restrict\r
33         guessing of the From: header.\r
34 In-Reply-To: <1328388317-20161-2-git-send-email-markwalters1009@gmail.com>\r
35 References: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com>\r
36         <1328388317-20161-2-git-send-email-markwalters1009@gmail.com>\r
37 User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1\r
38         (i686-pc-linux-gnu)\r
39 Date: Sun, 05 Feb 2012 00:07:41 +0200\r
40 Message-ID: <87haz68d76.fsf@nikula.org>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Sat, 04 Feb 2012 22:07:49 -0000\r
56 \r
57 On Sat,  4 Feb 2012 20:45:14 +0000, Mark Walters <markwalters1009@gmail.com> wrote:\r
58 > Add an option --from= to notmuch-reply.c to restrict guessing of the\r
59 > From: header. The existing logic looks as the main headers, then at\r
60 > the delivery headers, and finally defaults to the config file address.\r
61\r
62 > This patch allows the user to restrict which of these guesses are\r
63 > made.  Currently the supported values are:\r
64 >        default|fallback-all    current behaviour\r
65 >        fallback-received       fallback to delivery headers but not config file\r
66 >        fallback-none         only look at from/reply-to/to/cc/ headers\r
67 >        none                  From: header is always left empty\r
68 \r
69 The patch looks good. The "primary" option added in v2 is missing from\r
70 the commit message, but no need to send a new version because of that.\r
71 \r
72 I didn't check the other patches in the series.\r
73 \r
74 BR,\r
75 Jani.\r
76 \r
77 \r
78\r
79 > If the code does not find an allowed address it outputs an empty From:\r
80 > line and the caller can decide how to respond.\r
81 > ---\r
82 >  notmuch-reply.c |   45 ++++++++++++++++++++++++++++++++++++---------\r
83 >  1 files changed, 36 insertions(+), 9 deletions(-)\r
84\r
85 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
86 > index f55b1d2..8c73cb7 100644\r
87 > --- a/notmuch-reply.c\r
88 > +++ b/notmuch-reply.c\r
89 > @@ -24,6 +24,15 @@\r
90 >  #include "gmime-filter-reply.h"\r
91 >  #include "gmime-filter-headers.h"\r
92 >  \r
93 > +/* The order here matters as we use '<' when deciding how to behave. */\r
94 > +enum {\r
95 > +    FROM_FALLBACK_ALL,\r
96 > +    FROM_FALLBACK_RECEIVED,\r
97 > +    FROM_FALLBACK_NONE,\r
98 > +    FROM_NONE,\r
99 > +    FROM_PRIMARY\r
100 > +};\r
101 > +\r
102 >  static void\r
103 >  reply_headers_message_part (GMimeMessage *message);\r
104 >  \r
105 > @@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,\r
106 >                            notmuch_config_t *config,\r
107 >                            notmuch_query_t *query,\r
108 >                            notmuch_show_params_t *params,\r
109 > -                          notmuch_bool_t reply_all)\r
110 > +                          notmuch_bool_t reply_all,\r
111 > +                          int from_select)\r
112 >  {\r
113 >      GMimeMessage *reply;\r
114 >      notmuch_messages_t *messages;\r
115 > @@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,\r
116 >       from_addr = add_recipients_from_message (reply, config, message,\r
117 >                                                reply_all);\r
118 >  \r
119 > -     if (from_addr == NULL)\r
120 > +     if (from_addr == NULL && from_select <= FROM_FALLBACK_RECEIVED)\r
121 >           from_addr = guess_from_received_header (config, message);\r
122 >  \r
123 > -     if (from_addr == NULL)\r
124 > +     if ((from_addr == NULL && from_select <= FROM_FALLBACK_ALL) ||\r
125 > +         from_select == FROM_PRIMARY)\r
126 >           from_addr = notmuch_config_get_user_primary_email (config);\r
127 >  \r
128 > -     from_addr = talloc_asprintf (ctx, "%s <%s>",\r
129 > -                                  notmuch_config_get_user_name (config),\r
130 > -                                  from_addr);\r
131 > +     /* If we have an address and we want an address print\r
132 > +      * it. Otherwise set an empty From: header. */\r
133 > +     if (from_addr != NULL && from_select != FROM_NONE) {\r
134 > +         from_addr = talloc_asprintf (ctx, "%s <%s>",\r
135 > +                                      notmuch_config_get_user_name (config),\r
136 > +                                      from_addr);\r
137 > +     } else {\r
138 > +         from_addr = talloc_strdup (ctx, "");\r
139 > +     }\r
140 >       g_mime_object_set_header (GMIME_OBJECT (reply),\r
141 >                                 "From", from_addr);\r
142 >  \r
143 > @@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
144 >                                 notmuch_config_t *config,\r
145 >                                 notmuch_query_t *query,\r
146 >                                 unused (notmuch_show_params_t *params),\r
147 > -                               notmuch_bool_t reply_all)\r
148 > +                               notmuch_bool_t reply_all,\r
149 > +                               unused (int from_select))\r
150 >  {\r
151 >      GMimeMessage *reply;\r
152 >      notmuch_messages_t *messages;\r
153 > @@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
154 >      notmuch_query_t *query;\r
155 >      char *query_string;\r
156 >      int opt_index, ret = 0;\r
157 > -    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
158 > +    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
159 >      notmuch_show_params_t params = { .part = -1 };\r
160 >      int format = FORMAT_DEFAULT;\r
161 >      int reply_all = TRUE;\r
162 > +    int from_select = FROM_FALLBACK_ALL;\r
163 >      notmuch_bool_t decrypt = FALSE;\r
164 >  \r
165 >      notmuch_opt_desc_t options[] = {\r
166 > @@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
167 >         (notmuch_keyword_t []){ { "all", TRUE },\r
168 >                                 { "sender", FALSE },\r
169 >                                 { 0, 0 } } },\r
170 > +     { NOTMUCH_OPT_KEYWORD, &from_select, "from", 'F',\r
171 > +       (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },\r
172 > +                               { "fallback-all", FROM_FALLBACK_ALL },\r
173 > +                               { "fallback-received", FROM_FALLBACK_RECEIVED },\r
174 > +                               { "fallback-none", FROM_FALLBACK_NONE },\r
175 > +                               { "none", FROM_NONE },\r
176 > +                               { "primary", FROM_PRIMARY },\r
177 > +                               { 0, 0 } } },\r
178 >       { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
179 >       { 0, 0, 0, 0, 0 }\r
180 >      };\r
181 > @@ -732,7 +759,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
182 >       return 1;\r
183 >      }\r
184 >  \r
185 > -    if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
186 > +    if (reply_format_func (ctx, config, query, &params, reply_all, from_select) != 0)\r
187 >       return 1;\r
188 >  \r
189 >      notmuch_query_destroy (query);\r
190 > -- \r
191 > 1.7.2.3\r
192\r
193 > _______________________________________________\r
194 > notmuch mailing list\r
195 > notmuch@notmuchmail.org\r
196 > http://notmuchmail.org/mailman/listinfo/notmuch\r