--- /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 14050431FD5\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 14:54:29 -0700 (PDT)\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 X8KB1Hpax9qT for <notmuch@notmuchmail.org>;\r
+ Fri, 31 Oct 2014 14:54:20 -0700 (PDT)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 03585431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 14:54:19 -0700 (PDT)\r
+Received: from localhost (unknown [192.168.200.7])\r
+ by max.feld.cvut.cz (Postfix) with ESMTP id 426915CD111\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 22:54:18 +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 Vb5qCUuKs-Zs for <notmuch@notmuchmail.org>;\r
+ Fri, 31 Oct 2014 22:54:14 +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 AA90D5CD10C\r
+ for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 22:54:14 +0100 (CET)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
+ (envelope-from <sojkam1@fel.cvut.cz>)\r
+ id 1XkK92-0007ha-L0; Fri, 31 Oct 2014 22:54:08 +0100\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v6 0/7] notmuch search --output=sender/recipients\r
+Date: Fri, 31 Oct 2014 22:53:54 +0100\r
+Message-Id: <1414792441-29555-1-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 2.1.1\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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: Fri, 31 Oct 2014 21:54:29 -0000\r
+\r
+Hi all,\r
+\r
+this is v6 of the search --output=address series. It obsoletes v5\r
+(id:1414713573-21461-1-git-send-email-sojkam1@fel.cvut.cz).\r
+\r
+Changes from v5 (full diff below):\r
+\r
+- Added quoting of name parts if that is necessary (pointed out by\r
+ Mark Walters). Structured formats contain both full address\r
+ (possibly with quoted name) and unquoted individual fields.\r
+- Fixed bug in --output=count --filter-by=*fold (reported by Jesse\r
+ Rosenthal). New test was added for this case. Fixing the bug also\r
+ resulted in simpler code :)\r
+- Added missing unreferencing of InternetAddressList.\r
+\r
+Changes from v4:\r
+\r
+- patch changed to commit in commit messages\r
+- opt->format changed to format\r
+- Added comments to process_* functions\r
+- duplicite changed to duplicate\r
+- check_duplicate changed to is_duplicate\r
+- Deduplication was split into two commits: basic deduplication\r
+ without a command line option and configurable deduplication with\r
+ --fiter-by.\r
+\r
+Changes from v3:\r
+\r
+- `o' renamed to `opt'.\r
+- Conversion of --output from keyword to keyword-flags is now a\r
+ separate patch.\r
+- Structured output formats print name and address separately.\r
+- Added test for --format=json.\r
+- Changed --filter-by default to nameaddr. In v2, the default was\r
+ addrfold, in v3 the default was no filtering at all. I believe that\r
+ Mark's suggestion to make nameaddr the default is good trade off.\r
+- Added new --output=count\r
+- Minor style fixes\r
+- Few typos fixed\r
+- There is no way to output unfiltered (duplicite) addresses.\r
+ Hopefully, the introduction of --output=count is sufficient\r
+ replacement for this "feature".\r
+\r
+Cheers,\r
+-Michal\r
+\r
+\r
+Jani Nikula (1):\r
+ cli: Add support for parsing keyword-flag arguments\r
+\r
+Michal Sojka (6):\r
+ cli: search: Refactor passing of command line options\r
+ cli: search: Convert --output to keyword-flag argument\r
+ cli: search: Add --output={sender,recipients}\r
+ cli: search: Do not output duplicate addresses\r
+ cli: search: Add --output=count\r
+ cli: search: Add --filter-by option to configure address filtering\r
+\r
+ command-line-arguments.c | 6 +-\r
+ command-line-arguments.h | 1 +\r
+ completion/notmuch-completion.bash | 8 +-\r
+ completion/notmuch-completion.zsh | 4 +-\r
+ doc/man1/notmuch-search.rst | 66 ++++++-\r
+ notmuch-search.c | 390 +++++++++++++++++++++++++++++--------\r
+ test/T090-search-output.sh | 87 +++++++++\r
+ test/T095-search-filter-by.sh | 73 +++++++\r
+ test/T410-argument-parsing.sh | 3 +-\r
+ test/arg-test.c | 9 +\r
+ 10 files changed, 565 insertions(+), 82 deletions(-)\r
+ create mode 100755 test/T095-search-filter-by.sh\r
+\r
+-- \r
+2.1.1\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 8bc80d3..a350f06 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -246,33 +246,35 @@ is_duplicate (const search_options_t *opt, GHashTable *addrs, const char *name,\r
+ {\r
+ notmuch_bool_t duplicate;\r
+ char *key;\r
++ gchar *addrfold = NULL;\r
+ mailbox_t *mailbox;\r
+ \r
+ if (opt->filter_by == FILTER_BY_ADDRFOLD ||\r
+- opt->filter_by == FILTER_BY_NAMEADDRFOLD) {\r
+- gchar *folded = g_utf8_casefold (addr, -1);\r
+- addr = talloc_strdup (opt->format, folded);\r
+- g_free (folded);\r
+- }\r
++ opt->filter_by == FILTER_BY_NAMEADDRFOLD)\r
++ addrfold = g_utf8_casefold (addr, -1);\r
++\r
+ switch (opt->filter_by) {\r
+ case FILTER_BY_NAMEADDR:\r
+- case FILTER_BY_NAMEADDRFOLD:\r
+ key = talloc_asprintf (opt->format, "%s <%s>", name, addr);\r
+ break;\r
++ case FILTER_BY_NAMEADDRFOLD:\r
++ key = talloc_asprintf (opt->format, "%s <%s>", name, addrfold);\r
++ break;\r
+ case FILTER_BY_NAME:\r
+ key = talloc_strdup (opt->format, name); /* !name results in !key */\r
+ break;\r
+ case FILTER_BY_ADDR:\r
+- case FILTER_BY_ADDRFOLD:\r
+ key = talloc_strdup (opt->format, addr);\r
+ break;\r
++ case FILTER_BY_ADDRFOLD:\r
++ key = talloc_strdup (opt->format, addrfold);\r
++ break;\r
+ default:\r
+ INTERNAL_ERROR("invalid --filter-by flags");\r
+ }\r
+ \r
+- if (opt->filter_by == FILTER_BY_ADDRFOLD ||\r
+- opt->filter_by == FILTER_BY_NAMEADDRFOLD)\r
+- talloc_free ((char*)addr);\r
++ if (addrfold)\r
++ g_free (addrfold);\r
+ \r
+ if (! key)\r
+ return FALSE;\r
+@@ -300,33 +302,28 @@ print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)\r
+ const char *addr = mailbox->addr;\r
+ int count = mailbox->count;\r
+ sprinter_t *format = opt->format;\r
++ InternetAddress *ia = internet_address_mailbox_new (name, addr);\r
++ char *name_addr;\r
+ \r
+- if (format->is_text_printer) {\r
+- char *mailbox_str;\r
++ /* name_addr has the name part quoted if necessary. Compare\r
++ * 'John Doe <john@doe.com>' vs. '"Doe, John" <john@doe.com>' */\r
++ name_addr = internet_address_to_string (ia, FALSE);\r
+ \r
+- if (name && *name)\r
+- mailbox_str = talloc_asprintf (format, "%s <%s>", name, addr);\r
+- else\r
+- mailbox_str = talloc_strdup (format, addr);\r
+-\r
+- if (! mailbox_str) {\r
+- fprintf (stderr, "Error: out of memory\n");\r
+- return;\r
+- }\r
++ if (format->is_text_printer) {\r
+ if (count > 0) {\r
+ format->integer (format, count);\r
+ format->string (format, "\t");\r
+ }\r
+- format->string (format, mailbox_str);\r
++ format->string (format, name_addr);\r
+ format->separator (format);\r
+-\r
+- talloc_free (mailbox_str);\r
+ } else {\r
+ format->begin_map (format);\r
+ format->map_key (format, "name");\r
+ format->string (format, name);\r
+ format->map_key (format, "address");\r
+ format->string (format, addr);\r
++ format->map_key (format, "name-addr");\r
++ format->string (format, name_addr);\r
+ if (count > 0) {\r
+ format->map_key (format, "count");\r
+ format->integer (format, count);\r
+@@ -334,6 +331,9 @@ print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)\r
+ format->end (format);\r
+ format->separator (format);\r
+ }\r
++\r
++ g_object_unref (ia);\r
++ g_free (name_addr);\r
+ }\r
+ \r
+ /* Print or prepare for printing addresses from InternetAddressList. */\r
+@@ -389,6 +389,8 @@ process_address_header (const search_options_t *opt, GHashTable *addrs, const ch\r
+ return;\r
+ \r
+ process_address_list (opt, addrs, list);\r
++\r
++ g_object_unref (list);\r
+ }\r
+ \r
+ static void\r
+diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh\r
+index 5a9bbc9..82380ac 100755\r
+--- a/test/T090-search-output.sh\r
++++ b/test/T090-search-output.sh\r
+@@ -413,73 +413,23 @@ test_expect_equal_file OUTPUT EXPECTED\r
+ test_begin_subtest "--output=sender --format=json"\r
+ notmuch search --output=sender --format=json '*' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-[{"name": "François Boulogne", "address": "boulogne.f@gmail.com"},\r
+-{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu"},\r
+-{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk"},\r
+-{"name": "Carl Worth", "address": "cworth@cworth.org"},\r
+-{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com"},\r
+-{"name": "Keith Packard", "address": "keithp@keithp.com"},\r
+-{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com"},\r
+-{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com"},\r
+-{"name": "Jan Janak", "address": "jan@ryngle.com"},\r
+-{"name": "Stewart Smith", "address": "stewart@flamingspork.com"},\r
+-{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu"},\r
+-{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com"},\r
+-{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org"},\r
+-{"name": "Aron Griffis", "address": "agriffis@n01se.net"},\r
+-{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com"},\r
+-{"name": "Israel Herraiz", "address": "isra@herraiz.org"},\r
+-{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net"}]\r
+-EOF\r
+-test_expect_equal_file OUTPUT EXPECTED\r
+-\r
+-test_begin_subtest "--output=sender --output=count"\r
+-notmuch search --output=sender --output=count '*' | sort -n >OUTPUT\r
+-cat <<EOF >EXPECTED\r
+-1 Adrian Perez de Castro <aperez@igalia.com>\r
+-1 Aron Griffis <agriffis@n01se.net>\r
+-1 Chris Wilson <chris@chris-wilson.co.uk>\r
+-1 François Boulogne <boulogne.f@gmail.com>\r
+-1 Ingmar Vanhassel <ingmar@exherbo.org>\r
+-1 Israel Herraiz <isra@herraiz.org>\r
+-1 Olivier Berger <olivier.berger@it-sudparis.eu>\r
+-1 Rolland Santimano <rollandsantimano@yahoo.com>\r
+-2 Alex Botero-Lowry <alex.boterolowry@gmail.com>\r
+-2 Jjgod Jiang <gzjjgod@gmail.com>\r
+-3 Stewart Smith <stewart@flamingspork.com>\r
+-4 Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
+-4 Jan Janak <jan@ryngle.com>\r
+-5 Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
+-5 Mikhail Gusarov <dottedmag@dottedmag.net>\r
+-7 Keith Packard <keithp@keithp.com>\r
+-12 Carl Worth <cworth@cworth.org>\r
+-EOF\r
+-test_expect_equal_file OUTPUT EXPECTED\r
+-\r
+-test_begin_subtest "--output=sender --output=count --format=json"\r
+-# Since the iteration order of GHashTable is not specified, we\r
+-# preprocess and sort the results to keep the order stable here.\r
+-notmuch search --output=sender --output=count --format=json '*' | \\r
+- sed -e 's/^\[//' -e 's/]$//' -e 's/,$//' | \\r
+- sort --field-separator=":" --key=4n --key=2 >OUTPUT\r
+-cat <<EOF >EXPECTED\r
+-{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "count": 1}\r
+-{"name": "Aron Griffis", "address": "agriffis@n01se.net", "count": 1}\r
+-{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "count": 1}\r
+-{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "count": 1}\r
+-{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "count": 1}\r
+-{"name": "Israel Herraiz", "address": "isra@herraiz.org", "count": 1}\r
+-{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "count": 1}\r
+-{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "count": 1}\r
+-{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "count": 2}\r
+-{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "count": 2}\r
+-{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "count": 3}\r
+-{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "count": 4}\r
+-{"name": "Jan Janak", "address": "jan@ryngle.com", "count": 4}\r
+-{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "count": 5}\r
+-{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "count": 5}\r
+-{"name": "Keith Packard", "address": "keithp@keithp.com", "count": 7}\r
+-{"name": "Carl Worth", "address": "cworth@cworth.org", "count": 12}\r
++[{"name": "François Boulogne", "address": "boulogne.f@gmail.com", "name-addr": "François Boulogne <boulogne.f@gmail.com>"},\r
++{"name": "Olivier Berger", "address": "olivier.berger@it-sudparis.eu", "name-addr": "Olivier Berger <olivier.berger@it-sudparis.eu>"},\r
++{"name": "Chris Wilson", "address": "chris@chris-wilson.co.uk", "name-addr": "Chris Wilson <chris@chris-wilson.co.uk>"},\r
++{"name": "Carl Worth", "address": "cworth@cworth.org", "name-addr": "Carl Worth <cworth@cworth.org>"},\r
++{"name": "Alexander Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alexander Botero-Lowry <alex.boterolowry@gmail.com>"},\r
++{"name": "Keith Packard", "address": "keithp@keithp.com", "name-addr": "Keith Packard <keithp@keithp.com>"},\r
++{"name": "Jjgod Jiang", "address": "gzjjgod@gmail.com", "name-addr": "Jjgod Jiang <gzjjgod@gmail.com>"},\r
++{"name": "Rolland Santimano", "address": "rollandsantimano@yahoo.com", "name-addr": "Rolland Santimano <rollandsantimano@yahoo.com>"},\r
++{"name": "Jan Janak", "address": "jan@ryngle.com", "name-addr": "Jan Janak <jan@ryngle.com>"},\r
++{"name": "Stewart Smith", "address": "stewart@flamingspork.com", "name-addr": "Stewart Smith <stewart@flamingspork.com>"},\r
++{"name": "Lars Kellogg-Stedman", "address": "lars@seas.harvard.edu", "name-addr": "Lars Kellogg-Stedman <lars@seas.harvard.edu>"},\r
++{"name": "Alex Botero-Lowry", "address": "alex.boterolowry@gmail.com", "name-addr": "Alex Botero-Lowry <alex.boterolowry@gmail.com>"},\r
++{"name": "Ingmar Vanhassel", "address": "ingmar@exherbo.org", "name-addr": "Ingmar Vanhassel <ingmar@exherbo.org>"},\r
++{"name": "Aron Griffis", "address": "agriffis@n01se.net", "name-addr": "Aron Griffis <agriffis@n01se.net>"},\r
++{"name": "Adrian Perez de Castro", "address": "aperez@igalia.com", "name-addr": "Adrian Perez de Castro <aperez@igalia.com>"},\r
++{"name": "Israel Herraiz", "address": "isra@herraiz.org", "name-addr": "Israel Herraiz <isra@herraiz.org>"},\r
++{"name": "Mikhail Gusarov", "address": "dottedmag@dottedmag.net", "name-addr": "Mikhail Gusarov <dottedmag@dottedmag.net>"}]\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+@@ -487,7 +437,7 @@ test_begin_subtest "--output=recipients"\r
+ notmuch search --output=recipients '*' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+ Allan McRae <allan@archlinux.org>\r
+-Discussion about the Arch User Repository (AUR) <aur-general@archlinux.org>\r
++"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux.org>\r
+ olivier.berger@it-sudparis.eu\r
+ notmuch@notmuchmail.org\r
+ notmuch <notmuch@notmuchmail.org>\r
+@@ -501,7 +451,7 @@ notmuch search --output=sender --output=recipients '*' >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+ François Boulogne <boulogne.f@gmail.com>\r
+ Allan McRae <allan@archlinux.org>\r
+-Discussion about the Arch User Repository (AUR) <aur-general@archlinux.org>\r
++"Discussion about the Arch User Repository (AUR)" <aur-general@archlinux.org>\r
+ Olivier Berger <olivier.berger@it-sudparis.eu>\r
+ olivier.berger@it-sudparis.eu\r
+ Chris Wilson <chris@chris-wilson.co.uk>\r
+diff --git a/test/T095-search-filter-by.sh b/test/T095-search-filter-by.sh\r
+index 97d9a9b..15c9f77 100755\r
+--- a/test/T095-search-filter-by.sh\r
++++ b/test/T095-search-filter-by.sh\r
+@@ -2,17 +2,17 @@\r
+ test_description='duplicite address filtering in "notmuch search --output=recipients"'\r
+ . ./test-lib.sh\r
+ \r
+-add_message '[to]="Real Name <foo@example.com>, Real Name <bar@example.com>"'\r
+-add_message '[to]="Nickname <foo@example.com>"' '[cc]="Real Name <Bar@Example.COM>"'\r
+-add_message '[to]="Nickname <foo@example.com>"' '[bcc]="Real Name <Bar@Example.COM>"'\r
++add_message '[to]="John Doe <foo@example.com>, John Doe <bar@example.com>"'\r
++add_message '[to]="\"Doe, John\" <foo@example.com>"' '[cc]="John Doe <Bar@Example.COM>"'\r
++add_message '[to]="\"Doe, John\" <foo@example.com>"' '[bcc]="John Doe <Bar@Example.COM>"'\r
+ \r
+ test_begin_subtest "--output=recipients"\r
+ notmuch search --output=recipients "*" >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Real Name <bar@example.com>\r
+-Nickname <foo@example.com>\r
+-Real Name <Bar@Example.COM>\r
++John Doe <foo@example.com>\r
++John Doe <bar@example.com>\r
++"Doe, John" <foo@example.com>\r
++John Doe <Bar@Example.COM>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+@@ -20,44 +20,53 @@ test_begin_subtest "--output=recipients --filter-by=nameaddr"\r
+ notmuch search --output=recipients --filter-by=nameaddr "*" >OUTPUT\r
+ # The same as above\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Real Name <bar@example.com>\r
+-Nickname <foo@example.com>\r
+-Real Name <Bar@Example.COM>\r
++John Doe <foo@example.com>\r
++John Doe <bar@example.com>\r
++"Doe, John" <foo@example.com>\r
++John Doe <Bar@Example.COM>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+ test_begin_subtest "--output=recipients --filter-by=name"\r
+ notmuch search --output=recipients --filter-by=name "*" >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Nickname <foo@example.com>\r
++John Doe <foo@example.com>\r
++"Doe, John" <foo@example.com>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+ test_begin_subtest "--output=recipients --filter-by=addr"\r
+ notmuch search --output=recipients --filter-by=addr "*" >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Real Name <bar@example.com>\r
+-Real Name <Bar@Example.COM>\r
++John Doe <foo@example.com>\r
++John Doe <bar@example.com>\r
++John Doe <Bar@Example.COM>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+ test_begin_subtest "--output=recipients --filter-by=addrfold"\r
+ notmuch search --output=recipients --filter-by=addrfold "*" >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Real Name <bar@example.com>\r
++John Doe <foo@example.com>\r
++John Doe <bar@example.com>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+ test_begin_subtest "--output=recipients --filter-by=nameaddrfold"\r
+ notmuch search --output=recipients --filter-by=nameaddrfold "*" >OUTPUT\r
+ cat <<EOF >EXPECTED\r
+-Real Name <foo@example.com>\r
+-Real Name <bar@example.com>\r
+-Nickname <foo@example.com>\r
++John Doe <foo@example.com>\r
++John Doe <bar@example.com>\r
++"Doe, John" <foo@example.com>\r
++EOF\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_begin_subtest "--output=recipients --filter-by=nameaddrfold --output=count"\r
++notmuch search --output=recipients --filter-by=nameaddrfold --output=count "*" | sort -n >OUTPUT\r
++cat <<EOF >EXPECTED\r
++1 John Doe <foo@example.com>\r
++2 "Doe, John" <foo@example.com>\r
++3 John Doe <bar@example.com>\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r