1 Return-Path: <sojkam1@fel.cvut.cz>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 1A2E9431FDE
\r
6 for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 16:26:34 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 3XMl5m7eayyf for <notmuch@notmuchmail.org>;
\r
16 Tue, 4 Nov 2014 16:26:26 -0800 (PST)
\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 17DD7431FBC
\r
19 for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 16:26:19 -0800 (PST)
\r
20 Received: from localhost (unknown [192.168.200.7])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 5424A5CD1B2
\r
22 for <notmuch@notmuchmail.org>; Wed, 5 Nov 2014 01:26:17 +0100 (CET)
\r
23 X-Virus-Scanned: IMAP STYX AMAVIS
\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])
\r
25 by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,
\r
26 port 10044) with ESMTP id 3cVnYzgdIhWy for <notmuch@notmuchmail.org>;
\r
27 Wed, 5 Nov 2014 01:26:13 +0100 (CET)
\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])
\r
29 by max.feld.cvut.cz (Postfix) with ESMTP id 943735CD1AA
\r
30 for <notmuch@notmuchmail.org>; Wed, 5 Nov 2014 01:26:13 +0100 (CET)
\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)
\r
32 (envelope-from <sojkam1@fel.cvut.cz>)
\r
33 id 1XloQI-0005Cd-NH; Wed, 05 Nov 2014 01:26:06 +0100
\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH v3 00/10] "notmuch address" command
\r
37 Date: Wed, 5 Nov 2014 01:25:49 +0100
\r
38 Message-Id: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz>
\r
39 X-Mailer: git-send-email 2.1.1
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 05 Nov 2014 00:26:34 -0000
\r
56 this is v3 of "notmuch address" patchset. It obsoletes [1].
\r
58 I think I addressed all comments made to v2. The diff between v2 and
\r
59 v3 is below. Besides this, I improved commit messages.
\r
61 I also tried to get rid of global variables in 6/10, but it looked
\r
62 ugly, because the definition of keywords (e.g. "text", "json", ...)
\r
63 had to be outside of option definition. So I kept the code as it was
\r
66 It seems that the agreement is to merge patches 1-9 for 0.19 and leave
\r
67 patch 10 for further discussion.
\r
72 [1] id:1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz
\r
76 cli: add support for hierarchical command line option arrays
\r
79 cli: search: Rename options to context
\r
80 cli: search: Move more variables into search_context_t
\r
81 cli: search: Convert ctx. to ctx->
\r
82 cli: search: Split notmuch_search_command to smaller functions
\r
83 cli: Introduce "notmuch address" command
\r
84 cli: search: Convert --output to keyword argument
\r
85 cli: address: Do not output duplicate addresses
\r
86 cli: address: Add --output=count
\r
87 cli: address: Add --filter-by option to configure address filtering
\r
89 command-line-arguments.c | 16 +-
\r
90 command-line-arguments.h | 1 +
\r
91 completion/notmuch-completion.bash | 48 +++-
\r
92 completion/notmuch-completion.zsh | 11 +-
\r
93 doc/man1/notmuch-address.rst | 132 +++++++++++
\r
94 doc/man1/notmuch-search.rst | 21 +-
\r
95 doc/man1/notmuch.rst | 7 +-
\r
96 notmuch-client.h | 3 +
\r
97 notmuch-search.c | 461 ++++++++++++++++++++++++++-----------
\r
99 test/T095-address.sh | 148 ++++++++++++
\r
100 test/T097-address-filter-by.sh | 73 ++++++
\r
101 12 files changed, 750 insertions(+), 173 deletions(-)
\r
102 create mode 100644 doc/man1/notmuch-address.rst
\r
103 create mode 100755 test/T095-address.sh
\r
104 create mode 100755 test/T097-address-filter-by.sh
\r
109 diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst
\r
110 index 524ab91..00582c3 100644
\r
111 --- a/doc/man1/notmuch-address.rst
\r
112 +++ b/doc/man1/notmuch-address.rst
\r
113 @@ -30,7 +30,7 @@ Supported options for **address** include
\r
114 intended for programs that invoke **notmuch(1)** internally. If
\r
115 omitted, the latest supported version will be used.
\r
117 - ``--output=(sender|recipients)``
\r
118 + ``--output=(sender|recipients|count)``
\r
120 Controls which information appears in the output. This option
\r
121 can be given multiple times to combine different outputs.
\r
122 @@ -64,7 +64,9 @@ Supported options for **address** include
\r
123 By default, results will be displayed in reverse chronological
\r
124 order, (that is, the newest results will be displayed first).
\r
126 - ``--exclude=(true|false|all|flag)``
\r
127 + This option has no effect when used with --output=count.
\r
129 + ``--exclude=(true|false)``
\r
130 A message is called "excluded" if it matches at least one tag in
\r
131 search.tag\_exclude that does not appear explicitly in the
\r
132 search terms. This option specifies whether to omit excluded
\r
133 @@ -73,18 +75,8 @@ Supported options for **address** include
\r
134 The default value, **true**, prevents excluded messages from
\r
135 matching the search terms.
\r
137 - **all** additionally prevents excluded messages from appearing
\r
138 - in displayed results, in effect behaving as though the excluded
\r
139 - messages do not exist.
\r
141 **false** allows excluded messages to match search terms and
\r
142 - appear in displayed results. Excluded messages are still marked
\r
143 - in the relevant outputs.
\r
145 - **flag** only has an effect when ``--output=summary``. The
\r
146 - output is almost identical to **false**, but the "match count"
\r
147 - is the number of matching non-excluded messages in the thread,
\r
148 - rather than the number of matching messages.
\r
149 + appear in displayed results.
\r
151 ``--filter-by=``\ (**nameaddr**\ \|\ **name** \|\ **addr**\ \|\ **addrfold**\ \|\ **nameaddrfold**\)
\r
153 diff --git a/notmuch-search.c b/notmuch-search.c
\r
154 index 04e33c6..246ec0a 100644
\r
155 --- a/notmuch-search.c
\r
156 +++ b/notmuch-search.c
\r
157 @@ -252,7 +252,9 @@ do_search_threads (search_context_t *ctx)
\r
161 -/* Returns TRUE iff name and/or addr is considered duplicate. */
\r
162 +/* Returns TRUE iff name and/or addr is considered duplicate. If not,
\r
163 + * stores the name/addr pair in order to detect subsequent
\r
165 static notmuch_bool_t
\r
166 is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
\r
168 @@ -405,8 +407,9 @@ process_address_header (const search_context_t *ctx, const char *value)
\r
169 g_object_unref (list);
\r
172 +/* Destructor for talloc-allocated GHashTable keys and values. */
\r
174 -_my_talloc_free_for_g_hash (void *ptr)
\r
175 +_talloc_free_for_g_hash (void *ptr)
\r
179 @@ -679,12 +682,6 @@ static const notmuch_opt_desc_t common_options[] = {
\r
180 { "text0", NOTMUCH_FORMAT_TEXT0 },
\r
182 { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 },
\r
183 - { NOTMUCH_OPT_KEYWORD, &search_context.exclude, "exclude", 'x',
\r
184 - (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
\r
185 - { "false", NOTMUCH_EXCLUDE_FALSE },
\r
186 - { "flag", NOTMUCH_EXCLUDE_FLAG },
\r
187 - { "all", NOTMUCH_EXCLUDE_ALL },
\r
192 @@ -702,6 +699,12 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
193 { "files", OUTPUT_FILES },
\r
194 { "tags", OUTPUT_TAGS },
\r
196 + { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
\r
197 + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
\r
198 + { "false", NOTMUCH_EXCLUDE_FALSE },
\r
199 + { "flag", NOTMUCH_EXCLUDE_FLAG },
\r
200 + { "all", NOTMUCH_EXCLUDE_ALL },
\r
202 { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },
\r
203 { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0 },
\r
204 { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0 },
\r
205 @@ -757,6 +760,10 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
\r
206 { "recipients", OUTPUT_RECIPIENTS },
\r
207 { "count", OUTPUT_COUNT },
\r
209 + { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
\r
210 + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
\r
211 + { "false", NOTMUCH_EXCLUDE_FALSE },
\r
213 { NOTMUCH_OPT_KEYWORD, &ctx->filter_by, "filter-by", 'b',
\r
214 (notmuch_keyword_t []){ { "nameaddr", FILTER_BY_NAMEADDR },
\r
215 { "name", FILTER_BY_NAME },
\r
216 @@ -774,14 +781,14 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
\r
217 return EXIT_FAILURE;
\r
220 - search_context.output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;
\r
221 + ctx->output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;
\r
223 if (_notmuch_search_prepare (ctx, config,
\r
224 argc - opt_index, argv + opt_index))
\r
225 return EXIT_FAILURE;
\r
227 ctx->addresses = g_hash_table_new_full (g_str_hash, g_str_equal,
\r
228 - _my_talloc_free_for_g_hash, _my_talloc_free_for_g_hash);
\r
229 + _talloc_free_for_g_hash, _talloc_free_for_g_hash);
\r
231 ret = do_search_messages (ctx);
\r
233 diff --git a/test/T095-address.sh b/test/T095-address.sh
\r
234 index 92e17b0..033d0f4 100755
\r
235 --- a/test/T095-address.sh
\r
236 +++ b/test/T095-address.sh
\r
237 @@ -91,8 +91,8 @@ Mikhail Gusarov <dottedmag@dottedmag.net>
\r
239 test_expect_equal_file OUTPUT EXPECTED
\r
241 -test_begin_subtest "No --output"
\r
242 -notmuch address --output=sender --output=recipients '*' >OUTPUT
\r
243 +test_begin_subtest "without --output"
\r
244 +notmuch address '*' >OUTPUT
\r
245 # Use EXPECTED from previous subtest
\r
246 test_expect_equal_file OUTPUT EXPECTED
\r