Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / f2 / cc108c814f1670dcedbcc84fb54e74c97c615e
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 861A6431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 10:00:06 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 gFmbbhrFt0GP for <notmuch@notmuchmail.org>;\r
16         Sat,  4 Feb 2012 10:00:05 -0800 (PST)\r
17 Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
18         [209.85.215.53]) (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 40EB2431FAF\r
21         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 10:00:05 -0800 (PST)\r
22 Received: by lahd3 with SMTP id d3so2606224lah.26\r
23         for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 10:00:03 -0800 (PST)\r
24 Received: by 10.152.132.133 with SMTP id ou5mr6097211lab.46.1328378403520;\r
25         Sat, 04 Feb 2012 10:00:03 -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 fl2sm8108488lbb.4.2012.02.04.10.00.00\r
29         (version=SSLv3 cipher=OTHER); Sat, 04 Feb 2012 10:00:02 -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 1/2] cli: add --from option to reply to restrict guessing\r
33         of the From: header.\r
34 In-Reply-To: <1328375350-10352-2-git-send-email-markwalters1009@gmail.com>\r
35 References: <1328375350-10352-1-git-send-email-markwalters1009@gmail.com>\r
36         <1328375350-10352-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: Sat, 04 Feb 2012 19:59:58 +0200\r
40 Message-ID: <87lioio4wx.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 18:00:06 -0000\r
56 \r
57 On Sat,  4 Feb 2012 17:09:09 +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 As discussed on IRC, --from=primary is a natural extension to always use\r
70 the primary address from config, but that can be a later patch.\r
71 \r
72\r
73 > If the code does not find an allowed address it outputs an empty From:\r
74 > line and the caller can decide how to respond.\r
75 > ---\r
76 >  notmuch-reply.c |   39 ++++++++++++++++++++++++++++++---------\r
77 >  1 files changed, 30 insertions(+), 9 deletions(-)\r
78\r
79 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
80 > index f55b1d2..f660749 100644\r
81 > --- a/notmuch-reply.c\r
82 > +++ b/notmuch-reply.c\r
83 > @@ -24,6 +24,13 @@\r
84 >  #include "gmime-filter-reply.h"\r
85 >  #include "gmime-filter-headers.h"\r
86 >  \r
87 \r
88 I think it would be good to have a comment here reminding later\r
89 developers that the order matters in this enum.\r
90 \r
91 > +enum {\r
92 > +    FROM_FALLBACK_ALL,\r
93 > +    FROM_FALLBACK_RECEIVED,\r
94 > +    FROM_FALLBACK_NONE,\r
95 > +    FROM_NONE\r
96 > +};\r
97 > +\r
98 >  static void\r
99 >  reply_headers_message_part (GMimeMessage *message);\r
100 >  \r
101 > @@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,\r
102 >                            notmuch_config_t *config,\r
103 >                            notmuch_query_t *query,\r
104 >                            notmuch_show_params_t *params,\r
105 > -                          notmuch_bool_t reply_all)\r
106 > +                          notmuch_bool_t reply_all,\r
107 > +                          int from_guess)\r
108 \r
109 Hrmh, I'd like this to sound more deterministic than\r
110 "guessing". from_select? from_use? from?\r
111 \r
112 >  {\r
113 >      GMimeMessage *reply;\r
114 >      notmuch_messages_t *messages;\r
115 > @@ -542,15 +550,19 @@ 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_guess <= FROM_FALLBACK_RECEIVED))\r
121 \r
122 Please drop the extra braces here and below.\r
123 \r
124 >           from_addr = guess_from_received_header (config, message);\r
125 >  \r
126 > -     if (from_addr == NULL)\r
127 > +     if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_ALL ))\r
128 >           from_addr = notmuch_config_get_user_primary_email (config);\r
129 >  \r
130 > -     from_addr = talloc_asprintf (ctx, "%s <%s>",\r
131 > -                                  notmuch_config_get_user_name (config),\r
132 > -                                  from_addr);\r
133 > +     if ((from_addr != NULL) || (from_guess = FROM_NONE)) {\r
134 \r
135 Should that be (from_addr != NULL && from_guess != FROM_NONE)?\r
136 Definitely the assignment is an error!\r
137 \r
138 > +         from_addr = talloc_asprintf (ctx, "%s <%s>",\r
139 > +                                      notmuch_config_get_user_name (config),\r
140 > +                                      from_addr);\r
141 > +     } else {\r
142 > +         from_addr = talloc_strdup (ctx, "");\r
143 > +     }\r
144 >       g_mime_object_set_header (GMIME_OBJECT (reply),\r
145 >                                 "From", from_addr);\r
146 >  \r
147 > @@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,\r
148 >                                 notmuch_config_t *config,\r
149 >                                 notmuch_query_t *query,\r
150 >                                 unused (notmuch_show_params_t *params),\r
151 > -                               notmuch_bool_t reply_all)\r
152 > +                               notmuch_bool_t reply_all,\r
153 > +                               unused (int from_guess))\r
154 >  {\r
155 >      GMimeMessage *reply;\r
156 >      notmuch_messages_t *messages;\r
157 > @@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
158 >      notmuch_query_t *query;\r
159 >      char *query_string;\r
160 >      int opt_index, ret = 0;\r
161 > -    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
162 > +    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_guess);\r
163 >      notmuch_show_params_t params = { .part = -1 };\r
164 >      int format = FORMAT_DEFAULT;\r
165 >      int reply_all = TRUE;\r
166 > +    int from_guess = FROM_FALLBACK_ALL;\r
167 >      notmuch_bool_t decrypt = FALSE;\r
168 >  \r
169 >      notmuch_opt_desc_t options[] = {\r
170 > @@ -672,6 +686,13 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
171 >         (notmuch_keyword_t []){ { "all", TRUE },\r
172 >                                 { "sender", FALSE },\r
173 >                                 { 0, 0 } } },\r
174 > +     { NOTMUCH_OPT_KEYWORD, &from_guess, "from", 'F',\r
175 > +       (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },\r
176 > +                               { "fallback-all", FROM_FALLBACK_ALL },\r
177 > +                               { "fallback-received", FROM_FALLBACK_RECEIVED },\r
178 > +                               { "fallback-none", FROM_FALLBACK_NONE },\r
179 > +                               { "none", FROM_NONE },\r
180 > +                               { 0, 0 } } },\r
181 >       { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
182 >       { 0, 0, 0, 0, 0 }\r
183 >      };\r
184 > @@ -732,7 +753,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
185 >       return 1;\r
186 >      }\r
187 >  \r
188 > -    if (reply_format_func (ctx, config, query, &params, reply_all) != 0)\r
189 > +    if (reply_format_func (ctx, config, query, &params, reply_all, from_guess) != 0)\r
190 >       return 1;\r
191 >  \r
192 >      notmuch_query_destroy (query);\r
193 > -- \r
194 > 1.7.2.3\r
195\r
196 > _______________________________________________\r
197 > notmuch mailing list\r
198 > notmuch@notmuchmail.org\r
199 > http://notmuchmail.org/mailman/listinfo/notmuch\r