--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 20B9D431FC7\r
+ for <notmuch@notmuchmail.org>; Thu, 30 Oct 2014 01:16:53 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, 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 xL21Vn0hML0p for <notmuch@notmuchmail.org>;\r
+ Thu, 30 Oct 2014 01:16:44 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 8435B431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 30 Oct 2014 01:16:43 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Xjku5-0006EO-SM; Thu, 30 Oct 2014 08:16:42 +0000\r
+Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1Xjku3-0001UO-45; Thu, 30 Oct 2014 08:16:21 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 5/6] cli: search: Add configurable way to filter\r
+ out duplicate addresses\r
+In-Reply-To: <1414421455-3037-6-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1414421455-3037-1-git-send-email-sojkam1@fel.cvut.cz>\r
+ <1414421455-3037-6-git-send-email-sojkam1@fel.cvut.cz>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 30 Oct 2014 08:16:18 +0000\r
+Message-ID: <87egtqug4t.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Sender-Host-Address: 87.81.223.162\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 9280583bd0e220ac2a1f2bae08d1669d (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.1\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -0.1 points.\r
+ Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.1 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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: Thu, 30 Oct 2014 08:16:53 -0000\r
+\r
+\r
+On Mon, 27 Oct 2014, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
+> This adds an algorithm to filter out duplicate addresses from address\r
+> outputs (sender, receivers). The algorithm can be configured with\r
+> --filter-by command line option.\r
+>\r
+> The code here is an extended version of a patch from Jani Nikula.\r
+\r
+Hi\r
+\r
+As this is getting into the more controversial bike shedding region I\r
+wonder if it would be worth splitting this into 2 patches: the first\r
+could do the default dedupe based on name/address and the second could\r
+do add the filter-by options.=20\r
+\r
+I think the default deduping is obviously worth doing but I am not sure\r
+about the rest. In any case I think the default deduping could go in\r
+pre-freeze but I would recommend the rest is left until after.\r
+\r
+> ---\r
+> completion/notmuch-completion.bash | 6 ++-\r
+> completion/notmuch-completion.zsh | 3 +-\r
+> doc/man1/notmuch-search.rst | 38 +++++++++++++++\r
+> notmuch-search.c | 98 ++++++++++++++++++++++++++++++++=\r
++++---\r
+> test/T090-search-output.sh | 87 +++++++++++++++++++++++++++++++++\r
+> test/T095-search-filter-by.sh | 64 +++++++++++++++++++++++++\r
+> 6 files changed, 288 insertions(+), 8 deletions(-)\r
+> create mode 100755 test/T095-search-filter-by.sh\r
+>\r
+> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-comp=\r
+letion.bash\r
+> index cfbd389..6b6d43a 100644\r
+> --- a/completion/notmuch-completion.bash\r
+> +++ b/completion/notmuch-completion.bash\r
+> @@ -305,12 +305,16 @@ _notmuch_search()\r
+> COMPREPLY=3D( $( compgen -W "true false flag all" -- "${cur}" ) )\r
+> return\r
+> ;;\r
+> + --filter-by)\r
+> + COMPREPLY=3D( $( compgen -W "nameaddr name addr addrfold nameaddrfo=\r
+ld" -- "${cur}" ) )\r
+> + return\r
+> + ;;\r
+> esac\r
+>=20=20\r
+> ! $split &&\r
+> case "${cur}" in\r
+> -*)\r
+> - local options=3D"--format=3D --output=3D --sort=3D --offset=3D --li=\r
+mit=3D --exclude=3D --duplicate=3D"\r
+> + local options=3D"--format=3D --output=3D --sort=3D --offset=3D --li=\r
+mit=3D --exclude=3D --duplicate=3D --filter-by=3D"\r
+> compopt -o nospace\r
+> COMPREPLY=3D( $(compgen -W "$options" -- ${cur}) )\r
+> ;;\r
+> diff --git a/completion/notmuch-completion.zsh b/completion/notmuch-compl=\r
+etion.zsh\r
+> index 3e52a00..3e535df 100644\r
+> --- a/completion/notmuch-completion.zsh\r
+> +++ b/completion/notmuch-completion.zsh\r
+> @@ -53,7 +53,8 @@ _notmuch_search()\r
+> '--max-threads=3D[display only the first x threads from the search r=\r
+esults]:number of threads to show: ' \\r
+> '--first=3D[omit the first x threads from the search results]:number=\r
+ of threads to omit: ' \\r
+> '--sort=3D[sort results]:sorting:((newest-first\:"reverse chronologi=\r
+cal order" oldest-first\:"chronological order"))' \\r
+> - '--output=3D[select what to output]:output:((summary threads message=\r
+s files tags sender recipients))'\r
+> + '--output=3D[select what to output]:output:((summary threads message=\r
+s files tags sender recipients))' \\r
+> + '--filter-by=3D[filter out duplicate addresses]:filter-by:((nameaddr=\r
+\:"both name and address part" name\:"name part" addr\:"address part" addrf=\r
+old\:"case-insensitive address part" nameaddrfold\:"name and case-insensiti=\r
+ve address part"))'\r
+> }\r
+>=20=20\r
+> _notmuch()\r
+> diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst\r
+> index b6607c9..84af2da 100644\r
+> --- a/doc/man1/notmuch-search.rst\r
+> +++ b/doc/man1/notmuch-search.rst\r
+> @@ -85,6 +85,9 @@ Supported options for **search** include\r
+> (--format=3Dtext0), as a JSON array (--format=3Djson), or as\r
+> an S-Expression list (--format=3Dsexp).\r
+>=20=20\r
+> + Duplicate addresses are filtered out. Filtering can be\r
+> + configured with the --filter-by option.\r
+> +\r
+> Note: Searching for **sender** should be much faster than\r
+> searching for **recipients**, because sender addresses are\r
+> cached directly in the database whereas other addresses\r
+> @@ -151,6 +154,41 @@ Supported options for **search** include\r
+> prefix. The prefix matches messages based on filenames. This\r
+> option filters filenames of the matching messages.\r
+>=20=20\r
+> + ``--filter-by=3D``\ (**nameaddr**\ \|\ **name** \|\ **addr**\ \|\ **=\r
+addrfold**\ \|\ **nameaddrfold**\)\r
+> +\r
+> + Can be used with ``--output=3Dsender`` or\r
+> + ``--output=3Drecipients`` to filter out duplicate addresses. The\r
+> + filtering algorithm receives a sequence of email addresses and\r
+> + outputs the same sequence without the addresses that are\r
+> + considered a duplicate of a previously output address. What is\r
+> + considered a duplicate depends on how the two addresses are\r
+> + compared and this can be controlled with the follwing flags:\r
+> +\r
+> + **nameaddr** means that both name and address parts are\r
+> + compared in case-sensitive manner. Therefore, all same looking\r
+> + addresses strings are considered duplicate. This is the\r
+> + default.\r
+> +\r
+> + **name** means that only the name part is compared (in\r
+> + case-sensitive manner). For example, the addresses "John Doe\r
+> + <me@example.com>" and "John Doe <john@doe.name>" will be\r
+> + considered duplicate.\r
+> +\r
+> + **addr** means that only the address part is compared (in\r
+> + case-sensitive manner). For example, the addresses "John Doe\r
+> + <john@example.com>" and "Dr. John Doe <john@example.com>" will\r
+> + be considered duplicate.\r
+> +\r
+> + **addrfold** is like **addr**, but comparison is done in\r
+> + canse-insensitive manner. For example, the addresses "John Doe\r
+> + <john@example.com>" and "Dr. John Doe <JOHN@EXAMPLE.COM>" will\r
+> + be considered duplicate.\r
+> +\r
+> + **nameaddrfold** is like **nameaddr**, but address comparison\r
+> + is done in canse-insensitive manner. For example, the\r
+> + addresses "John Doe <john@example.com>" and "John Doe\r
+> + <JOHN@EXAMPLE.COM>" will be considered duplicate.\r
+> +\r
+> EXIT STATUS\r
+> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r
+>=20=20\r
+> diff --git a/notmuch-search.c b/notmuch-search.c\r
+> index ce3bfb2..47aa979 100644\r
+> --- a/notmuch-search.c\r
+> +++ b/notmuch-search.c\r
+> @@ -34,6 +34,14 @@ typedef enum {\r
+>=20=20\r
+> #define OUTPUT_ADDRESS_FLAGS (OUTPUT_SENDER | OUTPUT_RECIPIENTS)\r
+>=20=20\r
+> +typedef enum {\r
+> + FILTER_BY_NAMEADDR =3D 0,\r
+> + FILTER_BY_NAME,\r
+> + FILTER_BY_ADDR,\r
+> + FILTER_BY_ADDRFOLD,\r
+> + FILTER_BY_NAMEADDRFOLD,\r
+> +} filter_by_t;\r
+> +\r
+> typedef struct {\r
+> sprinter_t *format;\r
+> notmuch_query_t *query;\r
+> @@ -42,6 +50,7 @@ typedef struct {\r
+> int offset;\r
+> int limit;\r
+> int dupe;\r
+> + filter_by_t filter_by;\r
+> } search_options_t;\r
+>=20=20\r
+> typedef struct {\r
+> @@ -229,6 +238,52 @@ do_search_threads (search_options_t *opt)\r
+> return 0;\r
+> }\r
+>=20=20\r
+> +/* Returns TRUE iff name and/or addr is considered duplicite. */\r
+\r
+A triviality; duplicite should be duplicate\r
+\r
+> +static notmuch_bool_t\r
+> +check_duplicite (const search_options_t *opt, GHashTable *addrs, const c=\r
+har *name, const char *addr)\r
+\r
+I am not sure on style but maybe is_duplicate would be clearer?\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+> +{\r
+> + notmuch_bool_t duplicite;\r
+> + char *key;\r
+> +\r
+> + if (opt->filter_by =3D=3D FILTER_BY_ADDRFOLD ||\r
+> + opt->filter_by =3D=3D FILTER_BY_NAMEADDRFOLD) {\r
+> + gchar *folded =3D g_utf8_casefold (addr, -1);\r
+> + addr =3D talloc_strdup (opt->format, folded);\r
+> + g_free (folded);\r
+> + }\r
+> + switch (opt->filter_by) {\r
+> + case FILTER_BY_NAMEADDR:\r
+> + case FILTER_BY_NAMEADDRFOLD:\r
+> + key =3D talloc_asprintf (opt->format, "%s <%s>", name, addr);\r
+> + break;\r
+> + case FILTER_BY_NAME:\r
+> + key =3D talloc_strdup (opt->format, name); /* !name results in !key */\r
+> + break;\r
+> + case FILTER_BY_ADDR:\r
+> + case FILTER_BY_ADDRFOLD:\r
+> + key =3D talloc_strdup (opt->format, addr);\r
+> + break;\r
+> + default:\r
+> + INTERNAL_ERROR("invalid --filter-by flags");\r
+> + }\r
+> +\r
+> + if (opt->filter_by =3D=3D FILTER_BY_ADDRFOLD ||\r
+> + opt->filter_by =3D=3D FILTER_BY_NAMEADDRFOLD)\r
+> + talloc_free ((char*)addr);\r
+> +\r
+> + if (! key)\r
+> + return FALSE;\r
+> +\r
+> + duplicite =3D g_hash_table_lookup_extended (addrs, key, NULL, NULL);\r
+> +\r
+> + if (! duplicite)\r
+> + g_hash_table_insert (addrs, key, NULL);\r
+> + else\r
+> + talloc_free (key);\r
+> +\r
+> + return duplicite;\r
+> +}\r
+> +\r
+> static void\r
+> print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)\r
+> {\r
+> @@ -263,7 +318,8 @@ print_mailbox (const search_options_t *opt, const mai=\r
+lbox_t *mailbox)\r
+> }\r
+>=20=20\r
+> static void\r
+> -process_address_list (const search_options_t *opt, InternetAddressList *=\r
+list)\r
+> +process_address_list (const search_options_t *opt, GHashTable *addrs,\r
+> + InternetAddressList *list)\r
+> {\r
+> InternetAddress *address;\r
+> int i;\r
+> @@ -279,7 +335,7 @@ process_address_list (const search_options_t *opt, In=\r
+ternetAddressList *list)\r
+> if (group_list =3D=3D NULL)\r
+> continue;\r
+>=20=20\r
+> - process_address_list (opt, group_list);\r
+> + process_address_list (opt, addrs, group_list);\r
+> } else {\r
+> InternetAddressMailbox *mailbox =3D INTERNET_ADDRESS_MAILBOX (addre=\r
+ss);\r
+> mailbox_t mbx =3D {\r
+> @@ -287,13 +343,16 @@ process_address_list (const search_options_t *opt, =\r
+InternetAddressList *list)\r
+> .addr =3D internet_address_mailbox_get_addr (mailbox),\r
+> };\r
+>=20=20\r
+> + if (check_duplicite (opt, addrs, mbx.name, mbx.addr))\r
+> + continue;\r
+> +\r
+> print_mailbox (opt, &mbx);\r
+> }\r
+> }\r
+> }\r
+>=20=20\r
+> static void\r
+> -process_address_header (const search_options_t *opt, const char *value)\r
+> +process_address_header (const search_options_t *opt, GHashTable *addrs, =\r
+const char *value)\r
+> {\r
+> InternetAddressList *list;\r
+>=20=20\r
+> @@ -304,7 +363,13 @@ process_address_header (const search_options_t *opt,=\r
+ const char *value)\r
+> if (list =3D=3D NULL)\r
+> return;\r
+>=20=20\r
+> - process_address_list (opt, list);\r
+> + process_address_list (opt, addrs, list);\r
+> +}\r
+> +\r
+> +static void\r
+> +_my_talloc_free_for_g_hash (void *ptr)\r
+> +{\r
+> + talloc_free (ptr);\r
+> }\r
+>=20=20\r
+> static int\r
+> @@ -314,8 +379,13 @@ do_search_messages (search_options_t *opt)\r
+> notmuch_messages_t *messages;\r
+> notmuch_filenames_t *filenames;\r
+> sprinter_t *format =3D opt->format;\r
+> + GHashTable *addresses =3D NULL;\r
+> int i;\r
+>=20=20\r
+> + if (opt->output & OUTPUT_ADDRESS_FLAGS)\r
+> + addresses =3D g_hash_table_new_full (g_str_hash, g_str_equal,\r
+> + _my_talloc_free_for_g_hash, NULL);\r
+> +\r
+> if (opt->offset < 0) {\r
+> opt->offset +=3D notmuch_query_count_messages (opt->query);\r
+> if (opt->offset < 0)\r
+> @@ -363,7 +433,7 @@ do_search_messages (search_options_t *opt)\r
+> const char *addrs;\r
+>=20=20\r
+> addrs =3D notmuch_message_get_header (message, "from");\r
+> - process_address_header (opt, addrs);\r
+> + process_address_header (opt, addresses, addrs);\r
+> }\r
+>=20=20\r
+> if (opt->output & OUTPUT_RECIPIENTS) {\r
+> @@ -373,7 +443,7 @@ do_search_messages (search_options_t *opt)\r
+>=20=20\r
+> for (j =3D 0; j < ARRAY_SIZE (hdrs); j++) {\r
+> addrs =3D notmuch_message_get_header (message, hdrs[j]);\r
+> - process_address_header (opt, addrs);\r
+> + process_address_header (opt, addresses, addrs);\r
+> }\r
+> }\r
+> }\r
+> @@ -381,6 +451,9 @@ do_search_messages (search_options_t *opt)\r
+> notmuch_message_destroy (message);\r
+> }\r
+>=20=20\r
+> + if (addresses)\r
+> + g_hash_table_unref (addresses);\r
+> +\r
+> notmuch_messages_destroy (messages);\r
+>=20=20\r
+> format->end (format);\r
+> @@ -447,6 +520,7 @@ notmuch_search_command (notmuch_config_t *config, int=\r
+ argc, char *argv[])\r
+> .offset =3D 0,\r
+> .limit =3D -1, /* unlimited */\r
+> .dupe =3D -1,\r
+> + .filter_by =3D FILTER_BY_NAMEADDR,\r
+> };\r
+> char *query_str;\r
+> int opt_index, ret;\r
+> @@ -490,6 +564,13 @@ notmuch_search_command (notmuch_config_t *config, in=\r
+t argc, char *argv[])\r
+> { NOTMUCH_OPT_INT, &opt.offset, "offset", 'O', 0 },\r
+> { NOTMUCH_OPT_INT, &opt.limit, "limit", 'L', 0 },\r
+> { NOTMUCH_OPT_INT, &opt.dupe, "duplicate", 'D', 0 },\r
+> + { NOTMUCH_OPT_KEYWORD, &opt.filter_by, "filter-by", 'b',\r
+> + (notmuch_keyword_t []){ { "nameaddr", FILTER_BY_NAMEADDR },\r
+> + { "name", FILTER_BY_NAME },\r
+> + { "addr", FILTER_BY_ADDR },\r
+> + { "addrfold", FILTER_BY_ADDRFOLD },\r
+> + { "nameaddrfold", FILTER_BY_NAMEADDRFOLD },\r
+> + { 0, 0 } } },\r
+> { 0, 0, 0, 0, 0 }\r
+> };\r
+>=20=20\r
+> @@ -500,6 +581,11 @@ notmuch_search_command (notmuch_config_t *config, in=\r
+t argc, char *argv[])\r
+> if (! opt.output)\r
+> opt.output =3D OUTPUT_SUMMARY;\r
+>=20=20\r
+> + if (opt.filter_by && !(opt.output & OUTPUT_ADDRESS_FLAGS)) {\r
+> + fprintf (stderr, "Error: --filter-by can only be used with address outp=\r
+ut.\n");\r
+> + return EXIT_FAILURE;\r
+> + }\r
+> +\r
+> switch (format_sel) {\r
+> case NOTMUCH_FORMAT_TEXT:\r
+> opt.format =3D sprinter_text_create (config, stdout);\r
+> diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh\r
+> index 947d572..841a721 100755\r
+> --- a/test/T090-search-output.sh\r
+> +++ b/test/T090-search-output.sh\r
+> @@ -387,6 +387,93 @@ cat <<EOF >EXPECTED\r
+> EOF\r
+> test_expect_equal_file OUTPUT EXPECTED\r
+>=20=20\r
+> +test_begin_subtest "--output=3Dsender"\r
+> +notmuch search --output=3Dsender '*' >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Fran=C3=A7ois Boulogne <boulogne.f@gmail.com>\r
+> +Olivier Berger <olivier.berger@it-sudparis.eu>\r
+> +Chris Wilson <chris@chris-wilson.co.uk>\r
+> +Carl Worth <cworth@cworth.org>\r
+> +Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
+> +Keith Packard <keithp@keithp.com>\r
+> +Jjgod Jiang <gzjjgod@gmail.com>\r
+> +Rolland Santimano <rollandsantimano@yahoo.com>\r
+> +Jan Janak <jan@ryngle.com>\r
+> +Stewart Smith <stewart@flamingspork.com>\r
+> +Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
+> +Alex Botero-Lowry <alex.boterolowry@gmail.com>\r
+> +Ingmar Vanhassel <ingmar@exherbo.org>\r
+> +Aron Griffis <agriffis@n01se.net>\r
+> +Adrian Perez de Castro <aperez@igalia.com>\r
+> +Israel Herraiz <isra@herraiz.org>\r
+> +Mikhail Gusarov <dottedmag@dottedmag.net>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Dsender --format=3Djson"\r
+> +notmuch search --output=3Dsender --format=3Djson '*' >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +[{"name": "Fran=C3=A7ois 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.co=\r
+m"},\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=3Drecipients"\r
+> +notmuch search --output=3Drecipients '*' >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Allan McRae <allan@archlinux.org>\r
+> +Discussion about the Arch User Repository (AUR) <aur-general@archlinux.o=\r
+rg>\r
+> +olivier.berger@it-sudparis.eu\r
+> +notmuch@notmuchmail.org\r
+> +notmuch <notmuch@notmuchmail.org>\r
+> +Keith Packard <keithp@keithp.com>\r
+> +Mikhail Gusarov <dottedmag@dottedmag.net>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Dsender --output=3Drecipients"\r
+> +notmuch search --output=3Dsender --output=3Drecipients '*' >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Fran=C3=A7ois Boulogne <boulogne.f@gmail.com>\r
+> +Allan McRae <allan@archlinux.org>\r
+> +Discussion about the Arch User Repository (AUR) <aur-general@archlinux.o=\r
+rg>\r
+> +Olivier Berger <olivier.berger@it-sudparis.eu>\r
+> +olivier.berger@it-sudparis.eu\r
+> +Chris Wilson <chris@chris-wilson.co.uk>\r
+> +notmuch@notmuchmail.org\r
+> +Carl Worth <cworth@cworth.org>\r
+> +Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
+> +Keith Packard <keithp@keithp.com>\r
+> +Jjgod Jiang <gzjjgod@gmail.com>\r
+> +Rolland Santimano <rollandsantimano@yahoo.com>\r
+> +Jan Janak <jan@ryngle.com>\r
+> +Stewart Smith <stewart@flamingspork.com>\r
+> +Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
+> +notmuch <notmuch@notmuchmail.org>\r
+> +Alex Botero-Lowry <alex.boterolowry@gmail.com>\r
+> +Ingmar Vanhassel <ingmar@exherbo.org>\r
+> +Aron Griffis <agriffis@n01se.net>\r
+> +Adrian Perez de Castro <aperez@igalia.com>\r
+> +Israel Herraiz <isra@herraiz.org>\r
+> +Mikhail Gusarov <dottedmag@dottedmag.net>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> test_begin_subtest "sanitize output for quoted-printable line-breaks in =\r
+author and subject"\r
+> add_message "[subject]=3D'two =3D?ISO-8859-1?Q?line=3D0A_subject?=3D\r
+> headers'"\r
+> diff --git a/test/T095-search-filter-by.sh b/test/T095-search-filter-by.sh\r
+> new file mode 100755\r
+> index 0000000..97d9a9b\r
+> --- /dev/null\r
+> +++ b/test/T095-search-filter-by.sh\r
+> @@ -0,0 +1,64 @@\r
+> +#!/usr/bin/env bash\r
+> +test_description=3D'duplicite address filtering in "notmuch search --out=\r
+put=3Drecipients"'\r
+> +. ./test-lib.sh\r
+> +\r
+> +add_message '[to]=3D"Real Name <foo@example.com>, Real Name <bar@example=\r
+.com>"'\r
+> +add_message '[to]=3D"Nickname <foo@example.com>"' '[cc]=3D"Real Name <Ba=\r
+r@Example.COM>"'\r
+> +add_message '[to]=3D"Nickname <foo@example.com>"' '[bcc]=3D"Real Name <B=\r
+ar@Example.COM>"'\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients"\r
+> +notmuch search --output=3Drecipients "*" >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
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Dnameaddr"\r
+> +notmuch search --output=3Drecipients --filter-by=3Dnameaddr "*" >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
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Dname"\r
+> +notmuch search --output=3Drecipients --filter-by=3Dname "*" >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Real Name <foo@example.com>\r
+> +Nickname <foo@example.com>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Daddr"\r
+> +notmuch search --output=3Drecipients --filter-by=3Daddr "*" >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Real Name <foo@example.com>\r
+> +Real Name <bar@example.com>\r
+> +Real Name <Bar@Example.COM>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Daddrfold"\r
+> +notmuch search --output=3Drecipients --filter-by=3Daddrfold "*" >OUTPUT\r
+> +cat <<EOF >EXPECTED\r
+> +Real Name <foo@example.com>\r
+> +Real Name <bar@example.com>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_begin_subtest "--output=3Drecipients --filter-by=3Dnameaddrfold"\r
+> +notmuch search --output=3Drecipients --filter-by=3Dnameaddrfold "*" >OUT=\r
+PUT\r
+> +cat <<EOF >EXPECTED\r
+> +Real Name <foo@example.com>\r
+> +Real Name <bar@example.com>\r
+> +Nickname <foo@example.com>\r
+> +EOF\r
+> +test_expect_equal_file OUTPUT EXPECTED\r
+> +\r
+> +test_done\r
+> --=20\r
+> 2.1.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r