Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 43 / 4bda2eb282e051072e1b6c6d425e1ed7c2f411
1 Return-Path: <tomi.ollila@iki.fi>\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 11D57429E59\r
6         for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:31:10 -0700 (PDT)\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 zVaZOPv815bD for <notmuch@notmuchmail.org>;\r
16         Sun, 18 Aug 2013 11:31:01 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 3D678431FDB\r
19         for <notmuch@notmuchmail.org>; Sun, 18 Aug 2013 11:31:01 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id DD5DB100086;\r
22         Sun, 18 Aug 2013 21:30:56 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, John Lenz <lenz@math.uic.edu>,\r
25         notmuch@notmuchmail.org\r
26 Subject: Re: cli: add --include-html option to notmuch show\r
27 In-Reply-To: <87k3jjutpf.fsf@nikula.org>\r
28 References: <notmuch-web-1372724382.450184839@www.wuzzeb.org>\r
29         <m27ggj1x29.fsf@guru.guru-group.fi>\r
30         <notmuch-web-1374719771.1588310986@www.wuzzeb.org>\r
31         <m2zjsxs0g1.fsf@guru.guru-group.fi>\r
32         <notmuch-web-1376754748.336647450@www.wuzzeb.org>\r
33         <87k3jjutpf.fsf@nikula.org>\r
34 User-Agent: Notmuch/0.16+3~g340c058 (http://notmuchmail.org) Emacs/24.3.1\r
35         (x86_64-unknown-linux-gnu)\r
36 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
37         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
38         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
39 Date: Sun, 18 Aug 2013 21:30:56 +0300\r
40 Message-ID: <m2wqni7swv.fsf@guru.guru-group.fi>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain\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: Sun, 18 Aug 2013 18:31:10 -0000\r
56 \r
57 On Sun, Aug 18 2013, Jani Nikula <jani@nikula.org> wrote:\r
58 \r
59 > On Sat, 17 Aug 2013, John Lenz <lenz@math.uic.edu> wrote:\r
60 >> On Sun Aug  4 14:47 -0500 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
61 >>> The next question is should we have new option as\r
62 >>> \r
63 >>> --include-html\r
64 >>> \r
65 >>> or as\r
66 >>> \r
67 >>> --include-html=(true|false)\r
68 >>> \r
69 >>> or even\r
70 >>> \r
71 >>> --body=(true|false|text-and-html)\r
72 >>> \r
73 >>> See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/\r
74 >>> and --body option in http://notmuchmail.org/manpages/notmuch-show-1/\r
75 >>> for comparison...\r
76 >>> \r
77 >>\r
78 >> I have no preference here, although I guess I would vote for\r
79 >> --include-html=(true|false) since adding it to --body makes the --body\r
80 >> options confusing: to make sense the body options should be\r
81 >> --body=(text|text-and-html|none) but of course you can't change that and\r
82 >> break the command line API.  Well, maybe you could add all three\r
83 >> --body=(text|text-and-html|none)  and still accept true/false for\r
84 >> compatibility.\r
85 >\r
86 > Hi John & Tomi -\r
87 >\r
88 > We could trivially amend the argument parser to |= the keyword values\r
89 > (instead of =) to allow specifying keywords arguments multiple times on\r
90 > the command line. With the keyword values specified as bit flags, we\r
91 > could then have 'notmuch show --body=text --body=html ...' return both\r
92 > text and html, and allow trivial future extension too.\r
93 >\r
94 > --body=true and --body=false could be handled specially for backwards\r
95 > compatibility, for example by forcing text only or no parts,\r
96 > respectively. Since the default is currently text, --body=none might be\r
97 > a suitable synonym for --body=false, while the boolean alternatives\r
98 > could be deprecated.\r
99 >\r
100 > A little less trivially it's also possible to support e.g. comma\r
101 > separated keyword values, such as --body=text,html but I do prefer the\r
102 > (implementation) simplicity of the above.\r
103 \r
104 I've also thought along these lines (except this possibility to give \r
105 argument multiple times)...\r
106 \r
107 But when I wrote my first reply I did not realise that the default\r
108 behaviour is to include all text/* parts *except* text/html. i.e.\r
109 text/html is excluded as as special case (and non-excluded parts\r
110 contain text/plain, text/calendar, text/whatnot etc...). \r
111 \r
112 How to do clean interface/implementation using --body is not trivial\r
113 (if possible). I played with options like\r
114 false/none -- true/text/plain -- all/textall/* and came to a conclusion\r
115 that maybe --include-html is the best option after all.\r
116 \r
117 Now, if we have --include-html should it be like that or \r
118 --include-html=(true|false). Currently we have both cases, adding\r
119 --verify, --decrypt, --create-folder, --batch, -no-hooks to the\r
120 set... I cannot get a clear opinion (without wast^H^H^H^H spending\r
121 excessive amount of time figuring these out) how this should be,\r
122 therefore I'm inclined to the opinion that\r
123 \r
124 the current patch from John with simple --include-html could be applied,\r
125 and in the future (if it is of anyone's interest) we update the parser\r
126 allowing boolean --arg equal --arg=true. Then it is just how we decide\r
127 to document these...\r
128 \r
129 Tomi\r
130 \r
131 >\r
132 > Untested patch to the argument parser below.\r
133 >\r
134 > Cheers,\r
135 > Jani.\r
136 >\r
137 >\r
138 > diff --git a/command-line-arguments.c b/command-line-arguments.c\r
139 > index bf9aeca..c426054 100644\r
140 > --- a/command-line-arguments.c\r
141 > +++ b/command-line-arguments.c\r
142 > @@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char\r
143 >      while (keywords->name) {\r
144 >       if (strcmp (arg_str, keywords->name) == 0) {\r
145 >           if (arg_desc->output_var) {\r
146 > -             *((int *)arg_desc->output_var) = keywords->value;\r
147 > +             if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)\r
148 > +                 *((int *)arg_desc->output_var) |= keywords->value;\r
149 > +             else\r
150 > +                 *((int *)arg_desc->output_var) = keywords->value;\r
151 >           }\r
152 >           return TRUE;\r
153 >       }\r
154 > @@ -146,6 +149,7 @@ parse_option (const char *arg,\r
155 >  \r
156 >           switch (try->opt_type) {\r
157 >           case NOTMUCH_OPT_KEYWORD:\r
158 > +         case NOTMUCH_OPT_KEYWORD_FLAGS:\r
159 >               return _process_keyword_arg (try, next, value);\r
160 >               break;\r
161 >           case NOTMUCH_OPT_BOOLEAN:\r
162 > diff --git a/command-line-arguments.h b/command-line-arguments.h\r
163 > index de1734a..085a492 100644\r
164 > --- a/command-line-arguments.h\r
165 > +++ b/command-line-arguments.h\r
166 > @@ -8,6 +8,7 @@ enum notmuch_opt_type {\r
167 >      NOTMUCH_OPT_BOOLEAN,     /* --verbose              */\r
168 >      NOTMUCH_OPT_INT,         /* --frob=8               */\r
169 >      NOTMUCH_OPT_KEYWORD,     /* --format=raw|json|text */\r
170 > +    NOTMUCH_OPT_KEYWORD_FLAGS,  /* the above with values OR'd together */\r
171 >      NOTMUCH_OPT_STRING,              /* --file=/tmp/gnarf.txt  */\r
172 >      NOTMUCH_OPT_POSITION     /* notmuch dump pos_arg   */\r
173 >  };\r
174 >\r
175 >\r
176 >\r
177 > _______________________________________________\r
178 > notmuch mailing list\r
179 > notmuch@notmuchmail.org\r
180 > http://notmuchmail.org/mailman/listinfo/notmuch\r