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