From: Michal Sojka Date: Wed, 5 Nov 2014 00:25:49 +0000 (+0100) Subject: [PATCH v3 00/10] "notmuch address" command X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1087122757864a3ec7bfcc0c49428e8b9f1f49c3;p=notmuch-archives.git [PATCH v3 00/10] "notmuch address" command --- diff --git a/57/2c5e2d4b6a6f7ecde6909050edaedd03375a6f b/57/2c5e2d4b6a6f7ecde6909050edaedd03375a6f new file mode 100644 index 000000000..82061b509 --- /dev/null +++ b/57/2c5e2d4b6a6f7ecde6909050edaedd03375a6f @@ -0,0 +1,247 @@ +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 1A2E9431FDE + for ; Tue, 4 Nov 2014 16:26:34 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[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 3XMl5m7eayyf for ; + Tue, 4 Nov 2014 16:26:26 -0800 (PST) +Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) + by olra.theworths.org (Postfix) with ESMTP id 17DD7431FBC + for ; Tue, 4 Nov 2014 16:26:19 -0800 (PST) +Received: from localhost (unknown [192.168.200.7]) + by max.feld.cvut.cz (Postfix) with ESMTP id 5424A5CD1B2 + for ; Wed, 5 Nov 2014 01:26:17 +0100 (CET) +X-Virus-Scanned: IMAP STYX AMAVIS +Received: from max.feld.cvut.cz ([192.168.200.1]) + by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, + port 10044) with ESMTP id 3cVnYzgdIhWy for ; + Wed, 5 Nov 2014 01:26:13 +0100 (CET) +Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) + by max.feld.cvut.cz (Postfix) with ESMTP id 943735CD1AA + for ; Wed, 5 Nov 2014 01:26:13 +0100 (CET) +Received: from wsh by steelpick.2x.cz with local (Exim 4.84) + (envelope-from ) + id 1XloQI-0005Cd-NH; Wed, 05 Nov 2014 01:26:06 +0100 +From: Michal Sojka +To: notmuch@notmuchmail.org +Subject: [PATCH v3 00/10] "notmuch address" command +Date: Wed, 5 Nov 2014 01:25:49 +0100 +Message-Id: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz> +X-Mailer: git-send-email 2.1.1 +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: Wed, 05 Nov 2014 00:26:34 -0000 + +Hi all, + +this is v3 of "notmuch address" patchset. It obsoletes [1]. + +I think I addressed all comments made to v2. The diff between v2 and +v3 is below. Besides this, I improved commit messages. + +I also tried to get rid of global variables in 6/10, but it looked +ugly, because the definition of keywords (e.g. "text", "json", ...) +had to be outside of option definition. So I kept the code as it was +in v2. + +It seems that the agreement is to merge patches 1-9 for 0.19 and leave +patch 10 for further discussion. + +Thanks +-Michal + +[1] id:1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz + + +Jani Nikula (1): + cli: add support for hierarchical command line option arrays + +Michal Sojka (9): + cli: search: Rename options to context + cli: search: Move more variables into search_context_t + cli: search: Convert ctx. to ctx-> + cli: search: Split notmuch_search_command to smaller functions + cli: Introduce "notmuch address" command + cli: search: Convert --output to keyword argument + cli: address: Do not output duplicate addresses + cli: address: Add --output=count + cli: address: Add --filter-by option to configure address filtering + + command-line-arguments.c | 16 +- + command-line-arguments.h | 1 + + completion/notmuch-completion.bash | 48 +++- + completion/notmuch-completion.zsh | 11 +- + doc/man1/notmuch-address.rst | 132 +++++++++++ + doc/man1/notmuch-search.rst | 21 +- + doc/man1/notmuch.rst | 7 +- + notmuch-client.h | 3 + + notmuch-search.c | 461 ++++++++++++++++++++++++++----------- + notmuch.c | 2 + + test/T095-address.sh | 148 ++++++++++++ + test/T097-address-filter-by.sh | 73 ++++++ + 12 files changed, 750 insertions(+), 173 deletions(-) + create mode 100644 doc/man1/notmuch-address.rst + create mode 100755 test/T095-address.sh + create mode 100755 test/T097-address-filter-by.sh + +-- +2.1.1 + +diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst +index 524ab91..00582c3 100644 +--- a/doc/man1/notmuch-address.rst ++++ b/doc/man1/notmuch-address.rst +@@ -30,7 +30,7 @@ Supported options for **address** include + intended for programs that invoke **notmuch(1)** internally. If + omitted, the latest supported version will be used. + +- ``--output=(sender|recipients)`` ++ ``--output=(sender|recipients|count)`` + + Controls which information appears in the output. This option + can be given multiple times to combine different outputs. +@@ -64,7 +64,9 @@ Supported options for **address** include + By default, results will be displayed in reverse chronological + order, (that is, the newest results will be displayed first). + +- ``--exclude=(true|false|all|flag)`` ++ This option has no effect when used with --output=count. ++ ++ ``--exclude=(true|false)`` + A message is called "excluded" if it matches at least one tag in + search.tag\_exclude that does not appear explicitly in the + search terms. This option specifies whether to omit excluded +@@ -73,18 +75,8 @@ Supported options for **address** include + The default value, **true**, prevents excluded messages from + matching the search terms. + +- **all** additionally prevents excluded messages from appearing +- in displayed results, in effect behaving as though the excluded +- messages do not exist. +- + **false** allows excluded messages to match search terms and +- appear in displayed results. Excluded messages are still marked +- in the relevant outputs. +- +- **flag** only has an effect when ``--output=summary``. The +- output is almost identical to **false**, but the "match count" +- is the number of matching non-excluded messages in the thread, +- rather than the number of matching messages. ++ appear in displayed results. + + ``--filter-by=``\ (**nameaddr**\ \|\ **name** \|\ **addr**\ \|\ **addrfold**\ \|\ **nameaddrfold**\) + +diff --git a/notmuch-search.c b/notmuch-search.c +index 04e33c6..246ec0a 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -252,7 +252,9 @@ do_search_threads (search_context_t *ctx) + return 0; + } + +-/* Returns TRUE iff name and/or addr is considered duplicate. */ ++/* Returns TRUE iff name and/or addr is considered duplicate. If not, ++ * stores the name/addr pair in order to detect subsequent ++ * duplicates. */ + static notmuch_bool_t + is_duplicate (const search_context_t *ctx, const char *name, const char *addr) + { +@@ -405,8 +407,9 @@ process_address_header (const search_context_t *ctx, const char *value) + g_object_unref (list); + } + ++/* Destructor for talloc-allocated GHashTable keys and values. */ + static void +-_my_talloc_free_for_g_hash (void *ptr) ++_talloc_free_for_g_hash (void *ptr) + { + talloc_free (ptr); + } +@@ -679,12 +682,6 @@ static const notmuch_opt_desc_t common_options[] = { + { "text0", NOTMUCH_FORMAT_TEXT0 }, + { 0, 0 } } }, + { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 }, +- { NOTMUCH_OPT_KEYWORD, &search_context.exclude, "exclude", 'x', +- (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, +- { "false", NOTMUCH_EXCLUDE_FALSE }, +- { "flag", NOTMUCH_EXCLUDE_FLAG }, +- { "all", NOTMUCH_EXCLUDE_ALL }, +- { 0, 0 } } }, + { 0, 0, 0, 0, 0 } + }; + +@@ -702,6 +699,12 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) + { "files", OUTPUT_FILES }, + { "tags", OUTPUT_TAGS }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x', ++ (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, ++ { "false", NOTMUCH_EXCLUDE_FALSE }, ++ { "flag", NOTMUCH_EXCLUDE_FLAG }, ++ { "all", NOTMUCH_EXCLUDE_ALL }, ++ { 0, 0 } } }, + { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 }, + { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 }, + { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 }, +@@ -757,6 +760,10 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]) + { "recipients", OUTPUT_RECIPIENTS }, + { "count", OUTPUT_COUNT }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x', ++ (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, ++ { "false", NOTMUCH_EXCLUDE_FALSE }, ++ { 0, 0 } } }, + { NOTMUCH_OPT_KEYWORD, &ctx->filter_by, "filter-by", 'b', + (notmuch_keyword_t []){ { "nameaddr", FILTER_BY_NAMEADDR }, + { "name", FILTER_BY_NAME }, +@@ -774,14 +781,14 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]) + return EXIT_FAILURE; + + if (! ctx->output) +- search_context.output = OUTPUT_SENDER | OUTPUT_RECIPIENTS; ++ ctx->output = OUTPUT_SENDER | OUTPUT_RECIPIENTS; + + if (_notmuch_search_prepare (ctx, config, + argc - opt_index, argv + opt_index)) + return EXIT_FAILURE; + + ctx->addresses = g_hash_table_new_full (g_str_hash, g_str_equal, +- _my_talloc_free_for_g_hash, _my_talloc_free_for_g_hash); ++ _talloc_free_for_g_hash, _talloc_free_for_g_hash); + + ret = do_search_messages (ctx); + +diff --git a/test/T095-address.sh b/test/T095-address.sh +index 92e17b0..033d0f4 100755 +--- a/test/T095-address.sh ++++ b/test/T095-address.sh +@@ -91,8 +91,8 @@ Mikhail Gusarov + EOF + test_expect_equal_file OUTPUT EXPECTED + +-test_begin_subtest "No --output" +-notmuch address --output=sender --output=recipients '*' >OUTPUT ++test_begin_subtest "without --output" ++notmuch address '*' >OUTPUT + # Use EXPECTED from previous subtest + test_expect_equal_file OUTPUT EXPECTED +