From: Michal Sojka Date: Tue, 4 Nov 2014 11:26:02 +0000 (+0100) Subject: Re: [PATCH v2 07/10] cli: search: Convert --output to keyword argument X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3644581c70c4a5085fdd2cf7f4bb576b27c08e1b;p=notmuch-archives.git Re: [PATCH v2 07/10] cli: search: Convert --output to keyword argument --- diff --git a/5b/9266c60b88acab196dec6fbb992f432837293f b/5b/9266c60b88acab196dec6fbb992f432837293f new file mode 100644 index 000000000..ebe2a420b --- /dev/null +++ b/5b/9266c60b88acab196dec6fbb992f432837293f @@ -0,0 +1,201 @@ +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 16903431FAE + for ; Tue, 4 Nov 2014 12:15:38 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.224 +X-Spam-Level: +X-Spam-Status: No, score=-1.224 tagged_above=-999 required=5 + tests=[DATE_IN_PAST_03_06=1.076, 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 pV09gCfaBywZ for ; + Tue, 4 Nov 2014 12:15:30 -0800 (PST) +X-Greylist: delayed 300 seconds by postgrey-1.32 at olra; + Tue, 04 Nov 2014 12:15:29 PST +Received: from relay.felk.cvut.cz (relay.felk.cvut.cz [147.32.80.7]) + by olra.theworths.org (Postfix) with ESMTP id CB225431FB6 + for ; Tue, 4 Nov 2014 12:15:29 -0800 (PST) +Received: from control.felk.cvut.cz (control.felk.cvut.cz [147.32.87.4]) + by relay.felk.cvut.cz (8.14.9/8.14.9) with ESMTP id sA4FZxMn036846; + Tue, 4 Nov 2014 16:36:00 +0100 (CET) (envelope-from sojka@merica.cz) +Received: from CONTROL/SpoolDir by control.felk.cvut.cz (Mercury 1.48); + 4 Nov 14 16:36:01 +0100 +Received: from SpoolDir by CONTROL (Mercury 1.48); 4 Nov 14 16:35:54 +0100 +Received: from rtime.felk.cvut.cz (147.32.86.92) by control.felk.cvut.cz + (Mercury 1.48) with ESMTP; 4 Nov 14 16:35:53 +0100 +Received: from localhost ([127.0.0.1] helo=steelpick.2x.cz) + by rtime.felk.cvut.cz with esmtp (Exim 4.80) + (envelope-from ) + id 1Xlg9A-0004xd-Vm; Tue, 04 Nov 2014 16:35:53 +0100 +Received: from wsh by steelpick.2x.cz with local (Exim 4.84) + (envelope-from ) + id 1XlcFO-0002OM-St; Tue, 04 Nov 2014 12:26:02 +0100 +From: Michal Sojka +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 07/10] cli: search: Convert --output to keyword + argument +In-Reply-To: <87389z4a1g.fsf@qmul.ac.uk> +References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz> + <1415058622-21162-8-git-send-email-sojkam1@fel.cvut.cz> + <87389z4a1g.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.18.2+157~ga00d359 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Tue, 04 Nov 2014 12:26:02 +0100 +Message-ID: <87d293mcl1.fsf@steelpick.2x.cz> +MIME-Version: 1.0 +Content-Type: text/plain +X-FELK-MailScanner-Information: +X-MailScanner-ID: sA4FZxMn036846 +X-FELK-MailScanner: Found to be clean +X-FELK-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, + score=1.093, required 6, BAYES_00 -0.50, DATE_IN_PAST_03_06 1.59, + HEADER_FROM_DIFFERENT_DOMAINS 0.00) +X-FELK-MailScanner-SpamScore: s +X-FELK-MailScanner-From: sojka@merica.cz +X-FELK-MailScanner-Watermark: 1415720167.13071@8ULxbe+NOiHFa8Z1Yt4Azg +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: Tue, 04 Nov 2014 20:15:38 -0000 + +On Tue, Nov 04 2014, Mark Walters wrote: +> Hi +> +> On Mon, 03 Nov 2014, Michal Sojka wrote: +>> Now, when address related outputs are in a separate command, it makes +>> no sense to combine multiple --output options in search command line. +>> Using switch statement to handle different outputs is more readable +>> than a series of if statements. +> +> I am not keen on this change: I think the user should always be able to +> force the default output by setting command line options (which should +> protect against future changes in the default). + +You can do this even with this patch. + +> Thus I would like to continue to allow --output=sender +> --output=recipients. + +This is allowed in notmuch address. This patch modifies only notmuch +search. Currently it makes no sense to run --output=files --output=tags +or other output combinations. + +> I do approve of making the default do something useful but whether it +> should be both or just sender (which is much faster) is unclear to me. + +Does this comment refer to 7/10 or to 6/10? + +I'd say it refers to the following line from 6/10. + +search_context.output = OUTPUT_SENDER | OUTPUT_RECIPIENTS; + +Even there you can override the default by command line option. This get +executed only if no --output appears on the command line. + +Thanks +-Michal + + +> +> Best wishes +> +> Mark +> +> +>> --- +>> doc/man1/notmuch-search.rst | 3 --- +>> notmuch-search.c | 25 +++++++++++++------------ +>> 2 files changed, 13 insertions(+), 15 deletions(-) +>> +>> diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst +>> index 65df288..0cc2911 100644 +>> --- a/doc/man1/notmuch-search.rst +>> +++ b/doc/man1/notmuch-search.rst +>> @@ -78,9 +78,6 @@ Supported options for **search** include +>> by null characters (--format=text0), as a JSON array +>> (--format=json), or as an S-Expression list (--format=sexp). +>> +>> - This option can be given multiple times to combine different +>> - outputs. +>> - +>> ``--sort=``\ (**newest-first**\ \|\ **oldest-first**) +>> This option can be used to present results in either +>> chronological order (**oldest-first**) or reverse chronological +>> diff --git a/notmuch-search.c b/notmuch-search.c +>> index cbd84f5..402e860 100644 +>> --- a/notmuch-search.c +>> +++ b/notmuch-search.c +>> @@ -593,7 +593,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> int opt_index, ret; +>> +>> notmuch_opt_desc_t options[] = { +>> - { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o', +>> + { NOTMUCH_OPT_KEYWORD, &ctx->output, "output", 'o', +>> (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY }, +>> { "threads", OUTPUT_THREADS }, +>> { "messages", OUTPUT_MESSAGES }, +>> @@ -607,13 +607,11 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> { 0, 0, 0, 0, 0 } +>> }; +>> +>> + ctx->output = OUTPUT_SUMMARY; +>> opt_index = parse_arguments (argc, argv, options, 1); +>> if (opt_index < 0) +>> return EXIT_FAILURE; +>> +>> - if (! ctx->output) +>> - ctx->output = OUTPUT_SUMMARY; +>> - +>> if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && +>> ctx->dupe != -1) { +>> fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); +>> @@ -624,17 +622,20 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> argc - opt_index, argv + opt_index)) +>> return EXIT_FAILURE; +>> +>> - if (ctx->output == OUTPUT_SUMMARY || +>> - ctx->output == OUTPUT_THREADS) +>> + switch (ctx->output) { +>> + case OUTPUT_SUMMARY: +>> + case OUTPUT_THREADS: +>> ret = do_search_threads (ctx); +>> - else if (ctx->output == OUTPUT_MESSAGES || +>> - ctx->output == OUTPUT_FILES) +>> + break; +>> + case OUTPUT_MESSAGES: +>> + case OUTPUT_FILES: +>> ret = do_search_messages (ctx); +>> - else if (ctx->output == OUTPUT_TAGS) +>> + break; +>> + case OUTPUT_TAGS: +>> ret = do_search_tags (ctx); +>> - else { +>> - fprintf (stderr, "Error: the combination of outputs is not supported.\n"); +>> - ret = 1; +>> + break; +>> + default: +>> + INTERNAL_ERROR ("Unexpected output"); +>> } +>> +>> _notmuch_search_cleanup (ctx); +>> -- +>> 2.1.1 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch