1 Return-Path: <m.walters@qmul.ac.uk>
\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 3C2E2431FCF
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Aug 2013 01:11:28 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 6eMmIpPch8JB for <notmuch@notmuchmail.org>;
\r
17 Sat, 24 Aug 2013 01:11:24 -0700 (PDT)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 92B7D431FBF
\r
22 for <notmuch@notmuchmail.org>; Sat, 24 Aug 2013 01:11:23 -0700 (PDT)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1VD8wH-00052i-4G; Sat, 24 Aug 2013 09:11:17 +0100
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1VD8wG-00014e-KV; Sat, 24 Aug 2013 09:11:16 +0100
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Tomi Ollila <tomi.ollila@iki.fi>, Jani Nikula <jani@nikula.org>,
\r
33 John Lenz <lenz@math.uic.edu>, notmuch@notmuchmail.org
\r
34 Subject: Re: cli: add --include-html option to notmuch show
\r
35 In-Reply-To: <m2wqni7swv.fsf@guru.guru-group.fi>
\r
36 References: <notmuch-web-1372724382.450184839@www.wuzzeb.org>
\r
37 <m27ggj1x29.fsf@guru.guru-group.fi>
\r
38 <notmuch-web-1374719771.1588310986@www.wuzzeb.org>
\r
39 <m2zjsxs0g1.fsf@guru.guru-group.fi>
\r
40 <notmuch-web-1376754748.336647450@www.wuzzeb.org>
\r
41 <87k3jjutpf.fsf@nikula.org> <m2wqni7swv.fsf@guru.guru-group.fi>
\r
42 User-Agent: Notmuch/0.15.2+192~g8222af3 (http://notmuchmail.org) Emacs/23.4.1
\r
43 (x86_64-pc-linux-gnu)
\r
44 Date: Sat, 24 Aug 2013 09:11:15 +0100
\r
45 Message-ID: <87txifzexo.fsf@qmul.ac.uk>
\r
47 Content-Type: text/plain; charset=us-ascii
\r
48 X-Sender-Host-Address: 93.97.24.31
\r
49 X-QM-SPAM-Info: Sender has good ham record. :)
\r
50 X-QM-Body-MD5: 7bb4f6896cbb7a1b1549b7813d4b0f3e (of first 20000 bytes)
\r
51 X-SpamAssassin-Score: 0.0
\r
52 X-SpamAssassin-SpamBar: /
\r
53 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
55 spam. We require at least 5.0 points to mark a message as spam.
\r
56 This message scored 0.0 points. Summary of the scoring:
\r
57 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
58 provider * (markwalters1009[at]gmail.com)
\r
59 * 0.0 AWL AWL: From: address is in the auto white-list
\r
60 X-QM-Scan-Virus: ClamAV says the message is clean
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Sat, 24 Aug 2013 08:11:28 -0000
\r
78 Overall I like this patch.
\r
80 On Sun, 18 Aug 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
81 > On Sun, Aug 18 2013, Jani Nikula <jani@nikula.org> wrote:
\r
83 >> On Sat, 17 Aug 2013, John Lenz <lenz@math.uic.edu> wrote:
\r
84 >>> On Sun Aug 4 14:47 -0500 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
85 >>>> The next question is should we have new option as
\r
91 >>>> --include-html=(true|false)
\r
95 >>>> --body=(true|false|text-and-html)
\r
97 >>>> See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/
\r
98 >>>> and --body option in http://notmuchmail.org/manpages/notmuch-show-1/
\r
99 >>>> for comparison...
\r
102 >>> I have no preference here, although I guess I would vote for
\r
103 >>> --include-html=(true|false) since adding it to --body makes the --body
\r
104 >>> options confusing: to make sense the body options should be
\r
105 >>> --body=(text|text-and-html|none) but of course you can't change that and
\r
106 >>> break the command line API. Well, maybe you could add all three
\r
107 >>> --body=(text|text-and-html|none) and still accept true/false for
\r
110 >> Hi John & Tomi -
\r
112 >> We could trivially amend the argument parser to |= the keyword values
\r
113 >> (instead of =) to allow specifying keywords arguments multiple times on
\r
114 >> the command line. With the keyword values specified as bit flags, we
\r
115 >> could then have 'notmuch show --body=text --body=html ...' return both
\r
116 >> text and html, and allow trivial future extension too.
\r
118 >> --body=true and --body=false could be handled specially for backwards
\r
119 >> compatibility, for example by forcing text only or no parts,
\r
120 >> respectively. Since the default is currently text, --body=none might be
\r
121 >> a suitable synonym for --body=false, while the boolean alternatives
\r
122 >> could be deprecated.
\r
124 >> A little less trivially it's also possible to support e.g. comma
\r
125 >> separated keyword values, such as --body=text,html but I do prefer the
\r
126 >> (implementation) simplicity of the above.
\r
128 > I've also thought along these lines (except this possibility to give
\r
129 > argument multiple times)...
\r
131 > But when I wrote my first reply I did not realise that the default
\r
132 > behaviour is to include all text/* parts *except* text/html. i.e.
\r
133 > text/html is excluded as as special case (and non-excluded parts
\r
134 > contain text/plain, text/calendar, text/whatnot etc...).
\r
136 > How to do clean interface/implementation using --body is not trivial
\r
137 > (if possible). I played with options like
\r
138 > false/none -- true/text/plain -- all/textall/* and came to a conclusion
\r
139 > that maybe --include-html is the best option after all.
\r
141 > Now, if we have --include-html should it be like that or
\r
142 > --include-html=(true|false). Currently we have both cases, adding
\r
143 > --verify, --decrypt, --create-folder, --batch, -no-hooks to the
\r
144 > set... I cannot get a clear opinion (without wast^H^H^H^H spending
\r
145 > excessive amount of time figuring these out) how this should be,
\r
146 > therefore I'm inclined to the opinion that
\r
148 > the current patch from John with simple --include-html could be applied,
\r
149 > and in the future (if it is of anyone's interest) we update the parser
\r
150 > allowing boolean --arg equal --arg=true. Then it is just how we decide
\r
151 > to document these...
\r
153 I agree with Tomi on all of these points.
\r
155 I think that with several patches floating around in this thread (the
\r
156 original, some test, Tomi's modified tests) it would be good to have a
\r
157 new candidate series submitted. I think it would get my +1.
\r
169 >> Untested patch to the argument parser below.
\r
175 >> diff --git a/command-line-arguments.c b/command-line-arguments.c
\r
176 >> index bf9aeca..c426054 100644
\r
177 >> --- a/command-line-arguments.c
\r
178 >> +++ b/command-line-arguments.c
\r
179 >> @@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
\r
180 >> while (keywords->name) {
\r
181 >> if (strcmp (arg_str, keywords->name) == 0) {
\r
182 >> if (arg_desc->output_var) {
\r
183 >> - *((int *)arg_desc->output_var) = keywords->value;
\r
184 >> + if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)
\r
185 >> + *((int *)arg_desc->output_var) |= keywords->value;
\r
187 >> + *((int *)arg_desc->output_var) = keywords->value;
\r
191 >> @@ -146,6 +149,7 @@ parse_option (const char *arg,
\r
193 >> switch (try->opt_type) {
\r
194 >> case NOTMUCH_OPT_KEYWORD:
\r
195 >> + case NOTMUCH_OPT_KEYWORD_FLAGS:
\r
196 >> return _process_keyword_arg (try, next, value);
\r
198 >> case NOTMUCH_OPT_BOOLEAN:
\r
199 >> diff --git a/command-line-arguments.h b/command-line-arguments.h
\r
200 >> index de1734a..085a492 100644
\r
201 >> --- a/command-line-arguments.h
\r
202 >> +++ b/command-line-arguments.h
\r
203 >> @@ -8,6 +8,7 @@ enum notmuch_opt_type {
\r
204 >> NOTMUCH_OPT_BOOLEAN, /* --verbose */
\r
205 >> NOTMUCH_OPT_INT, /* --frob=8 */
\r
206 >> NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
\r
207 >> + NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */
\r
208 >> NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */
\r
209 >> NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
\r
214 >> _______________________________________________
\r
215 >> notmuch mailing list
\r
216 >> notmuch@notmuchmail.org
\r
217 >> http://notmuchmail.org/mailman/listinfo/notmuch
\r
218 > _______________________________________________
\r
219 > notmuch mailing list
\r
220 > notmuch@notmuchmail.org
\r
221 > http://notmuchmail.org/mailman/listinfo/notmuch
\r