From: Mark Walters Date: Sat, 24 Aug 2013 08:11:15 +0000 (+0100) Subject: Re: cli: add --include-html option to notmuch show X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=150f87f2863ee31667d10f8d213edaecdf008c8e;p=notmuch-archives.git Re: cli: add --include-html option to notmuch show --- diff --git a/38/8d14638ee9fab073e10198b7712d10c165a9b1 b/38/8d14638ee9fab073e10198b7712d10c165a9b1 new file mode 100644 index 000000000..14389e6cb --- /dev/null +++ b/38/8d14638ee9fab073e10198b7712d10c165a9b1 @@ -0,0 +1,221 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3C2E2431FCF + for ; Sat, 24 Aug 2013 01:11:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6eMmIpPch8JB for ; + Sat, 24 Aug 2013 01:11:24 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 92B7D431FBF + for ; Sat, 24 Aug 2013 01:11:23 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1VD8wH-00052i-4G; Sat, 24 Aug 2013 09:11:17 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1VD8wG-00014e-KV; Sat, 24 Aug 2013 09:11:16 +0100 +From: Mark Walters +To: Tomi Ollila , Jani Nikula , + John Lenz , notmuch@notmuchmail.org +Subject: Re: cli: add --include-html option to notmuch show +In-Reply-To: +References: + + + + + <87k3jjutpf.fsf@nikula.org> +User-Agent: Notmuch/0.15.2+192~g8222af3 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Sat, 24 Aug 2013 09:11:15 +0100 +Message-ID: <87txifzexo.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 7bb4f6896cbb7a1b1549b7813d4b0f3e (of first 20000 bytes) +X-SpamAssassin-Score: 0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored 0.0 points. Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.0 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 24 Aug 2013 08:11:28 -0000 + + +Hi + +Overall I like this patch. + +On Sun, 18 Aug 2013, Tomi Ollila wrote: +> On Sun, Aug 18 2013, Jani Nikula wrote: +> +>> On Sat, 17 Aug 2013, John Lenz wrote: +>>> On Sun Aug 4 14:47 -0500 2013, Tomi Ollila wrote: +>>>> The next question is should we have new option as +>>>> +>>>> --include-html +>>>> +>>>> or as +>>>> +>>>> --include-html=(true|false) +>>>> +>>>> or even +>>>> +>>>> --body=(true|false|text-and-html) +>>>> +>>>> See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/ +>>>> and --body option in http://notmuchmail.org/manpages/notmuch-show-1/ +>>>> for comparison... +>>>> +>>> +>>> I have no preference here, although I guess I would vote for +>>> --include-html=(true|false) since adding it to --body makes the --body +>>> options confusing: to make sense the body options should be +>>> --body=(text|text-and-html|none) but of course you can't change that and +>>> break the command line API. Well, maybe you could add all three +>>> --body=(text|text-and-html|none) and still accept true/false for +>>> compatibility. +>> +>> Hi John & Tomi - +>> +>> We could trivially amend the argument parser to |= the keyword values +>> (instead of =) to allow specifying keywords arguments multiple times on +>> the command line. With the keyword values specified as bit flags, we +>> could then have 'notmuch show --body=text --body=html ...' return both +>> text and html, and allow trivial future extension too. +>> +>> --body=true and --body=false could be handled specially for backwards +>> compatibility, for example by forcing text only or no parts, +>> respectively. Since the default is currently text, --body=none might be +>> a suitable synonym for --body=false, while the boolean alternatives +>> could be deprecated. +>> +>> A little less trivially it's also possible to support e.g. comma +>> separated keyword values, such as --body=text,html but I do prefer the +>> (implementation) simplicity of the above. +> +> I've also thought along these lines (except this possibility to give +> argument multiple times)... +> +> But when I wrote my first reply I did not realise that the default +> behaviour is to include all text/* parts *except* text/html. i.e. +> text/html is excluded as as special case (and non-excluded parts +> contain text/plain, text/calendar, text/whatnot etc...). +> +> How to do clean interface/implementation using --body is not trivial +> (if possible). I played with options like +> false/none -- true/text/plain -- all/textall/* and came to a conclusion +> that maybe --include-html is the best option after all. +> +> Now, if we have --include-html should it be like that or +> --include-html=(true|false). Currently we have both cases, adding +> --verify, --decrypt, --create-folder, --batch, -no-hooks to the +> set... I cannot get a clear opinion (without wast^H^H^H^H spending +> excessive amount of time figuring these out) how this should be, +> therefore I'm inclined to the opinion that +> +> the current patch from John with simple --include-html could be applied, +> and in the future (if it is of anyone's interest) we update the parser +> allowing boolean --arg equal --arg=true. Then it is just how we decide +> to document these... + +I agree with Tomi on all of these points. + +I think that with several patches floating around in this thread (the +original, some test, Tomi's modified tests) it would be good to have a +new candidate series submitted. I think it would get my +1. + +Best wishes + +Mark + + + +> +> Tomi +> +>> +>> Untested patch to the argument parser below. +>> +>> Cheers, +>> Jani. +>> +>> +>> diff --git a/command-line-arguments.c b/command-line-arguments.c +>> index bf9aeca..c426054 100644 +>> --- a/command-line-arguments.c +>> +++ b/command-line-arguments.c +>> @@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char +>> while (keywords->name) { +>> if (strcmp (arg_str, keywords->name) == 0) { +>> if (arg_desc->output_var) { +>> - *((int *)arg_desc->output_var) = keywords->value; +>> + if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS) +>> + *((int *)arg_desc->output_var) |= keywords->value; +>> + else +>> + *((int *)arg_desc->output_var) = keywords->value; +>> } +>> return TRUE; +>> } +>> @@ -146,6 +149,7 @@ parse_option (const char *arg, +>> +>> switch (try->opt_type) { +>> case NOTMUCH_OPT_KEYWORD: +>> + case NOTMUCH_OPT_KEYWORD_FLAGS: +>> return _process_keyword_arg (try, next, value); +>> break; +>> case NOTMUCH_OPT_BOOLEAN: +>> diff --git a/command-line-arguments.h b/command-line-arguments.h +>> index de1734a..085a492 100644 +>> --- a/command-line-arguments.h +>> +++ b/command-line-arguments.h +>> @@ -8,6 +8,7 @@ enum notmuch_opt_type { +>> NOTMUCH_OPT_BOOLEAN, /* --verbose */ +>> NOTMUCH_OPT_INT, /* --frob=8 */ +>> NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */ +>> + NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */ +>> NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */ +>> NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */ +>> }; +>> +>> +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch