[PATCH 1/9] lib: read "property" terms from messages.
[notmuch-archives.git] / 80 / 2c53c762d5f958db78190e6a47902104a132c8
1 Return-Path: <m.walters@qmul.ac.uk>\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 1A6A2429E37\r
6         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 01:04:20 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id jeAy3YI0JqLn for <notmuch@notmuchmail.org>;\r
17         Tue,  4 Nov 2014 01:04:16 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 2F96F429E35\r
22         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 01:04:16 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1Xla28-0003yC-8v; Tue, 04 Nov 2014 09:04:14 +0000\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1Xla27-0003Nq-0I; Tue, 04 Nov 2014 09:04:11 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2 06/10] cli: Introduce "notmuch address" command\r
34 In-Reply-To: <1415058622-21162-7-git-send-email-sojkam1@fel.cvut.cz>\r
35 References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>\r
36         <1415058622-21162-7-git-send-email-sojkam1@fel.cvut.cz>\r
37 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Tue, 04 Nov 2014 09:04:10 +0000\r
40 Message-ID: <87zjc72v79.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 87.81.223.162\r
44 X-QM-Geographic: According to ripencc,\r
45         this message was delivered by a machine in Britain (UK) (GB).\r
46 X-QM-SPAM-Info: Sender has good ham record.  :)\r
47 X-QM-Body-MD5: 120a5edc719782ec92bb7896896d4ab1 (of first 20000 bytes)\r
48 X-SpamAssassin-Score: -0.1\r
49 X-SpamAssassin-SpamBar: /\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
51         determine if it is\r
52         spam. We require at least 5.0 points to mark a message as spam.\r
53         This message scored -0.1 points.\r
54         Summary of the scoring: \r
55         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
56         provider *      (markwalters1009[at]gmail.com)\r
57         * -0.1 AWL AWL: From: address is in the auto white-list\r
58 X-QM-Scan-Virus: ClamAV says the message is clean\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Tue, 04 Nov 2014 09:04:20 -0000\r
72 \r
73 On Mon, 03 Nov 2014, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
74 > This moves address-related functionality from search command to the\r
75 > new address command. The implementation shares almost all code and\r
76 > some command line options.\r
77 >\r
78 > Options --offset and --limit were intentionally not included in the\r
79 > address command, because they refer to messages numbers, which users\r
80 > do not see in the output. This could confuse users because, for\r
81 > example, they could see more addresses in the output that what was\r
82 > specified with --limit. This functionality can be correctly\r
83 > reimplemented for addresses later.\r
84 \r
85 I am not sure about this: we already have this anomaly for output=files\r
86 say. Also I can imagine calling notmuch address --limit=1000 ... to get\r
87 a bunch of recent addresses quickly and I really am wanting to look at\r
88 1000 messages, not collect 1000 addresses.\r
89 \r
90 Additionally, the 1000 message approach makes sense when we start\r
91 deduping whereas 1000 authors becomes unclear.\r
92 \r
93 >\r
94 > This was inspired by a patch from Jani Nikula.\r
95 > ---\r
96 >  completion/notmuch-completion.bash |  42 ++++++++++++++-\r
97 >  completion/notmuch-completion.zsh  |  10 +++-\r
98 >  doc/man1/notmuch-address.rst       |  99 ++++++++++++++++++++++++++++++++++++\r
99 >  doc/man1/notmuch-search.rst        |  20 +-------\r
100 >  doc/man1/notmuch.rst               |   7 +--\r
101 >  notmuch-client.h                   |   3 ++\r
102 >  notmuch-search.c                   | 101 +++++++++++++++++++++++++------------\r
103 >  notmuch.c                          |   2 +\r
104 >  8 files changed, 228 insertions(+), 56 deletions(-)\r
105 >  create mode 100644 doc/man1/notmuch-address.rst\r
106 >\r
107 > diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
108 > index cfbd389..94ea2d5 100644\r
109 > --- a/completion/notmuch-completion.bash\r
110 > +++ b/completion/notmuch-completion.bash\r
111 > @@ -294,7 +294,7 @@ _notmuch_search()\r
112 >           return\r
113 >           ;;\r
114 >       --output)\r
115 > -         COMPREPLY=( $( compgen -W "summary threads messages files tags sender recipients" -- "${cur}" ) )\r
116 > +         COMPREPLY=( $( compgen -W "summary threads messages files tags" -- "${cur}" ) )\r
117 >           return\r
118 >           ;;\r
119 >       --sort)\r
120 > @@ -320,6 +320,44 @@ _notmuch_search()\r
121 >      esac\r
122 >  }\r
123 >  \r
124 > +_notmuch_address()\r
125 > +{\r
126 > +    local cur prev words cword split\r
127 > +    _init_completion -s || return\r
128 > +\r
129 > +    $split &&\r
130 > +    case "${prev}" in\r
131 > +     --format)\r
132 > +         COMPREPLY=( $( compgen -W "json sexp text text0" -- "${cur}" ) )\r
133 > +         return\r
134 > +         ;;\r
135 > +     --output)\r
136 > +         COMPREPLY=( $( compgen -W "sender recipients" -- "${cur}" ) )\r
137 > +         return\r
138 > +         ;;\r
139 > +     --sort)\r
140 > +         COMPREPLY=( $( compgen -W "newest-first oldest-first" -- "${cur}" ) )\r
141 > +         return\r
142 > +         ;;\r
143 > +     --exclude)\r
144 > +         COMPREPLY=( $( compgen -W "true false flag all" -- "${cur}" ) )\r
145 > +         return\r
146 > +         ;;\r
147 > +    esac\r
148 > +\r
149 > +    ! $split &&\r
150 > +    case "${cur}" in\r
151 > +     -*)\r
152 > +         local options="--format= --output= --sort= --exclude="\r
153 > +         compopt -o nospace\r
154 > +         COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
155 > +         ;;\r
156 > +     *)\r
157 > +         _notmuch_search_terms\r
158 > +         ;;\r
159 > +    esac\r
160 > +}\r
161 > +\r
162 >  _notmuch_show()\r
163 >  {\r
164 >      local cur prev words cword split\r
165 > @@ -393,7 +431,7 @@ _notmuch_tag()\r
166 >  \r
167 >  _notmuch()\r
168 >  {\r
169 > -    local _notmuch_commands="compact config count dump help insert new reply restore search setup show tag"\r
170 > +    local _notmuch_commands="compact config count dump help insert new reply restore search address setup show tag"\r
171 >      local arg cur prev words cword split\r
172 >  \r
173 >      # require bash-completion with _init_completion\r
174 > diff --git a/completion/notmuch-completion.zsh b/completion/notmuch-completion.zsh\r
175 > index 3e52a00..c606b75 100644\r
176 > --- a/completion/notmuch-completion.zsh\r
177 > +++ b/completion/notmuch-completion.zsh\r
178 > @@ -10,6 +10,7 @@ _notmuch_commands()\r
179 >      'setup:interactively set up notmuch for first use'\r
180 >      'new:find and import any new message to the database'\r
181 >      'search:search for messages matching the search terms, display matching threads as results'\r
182 > +    'address:get addresses from messages matching the given search terms'\r
183 >      'reply:constructs a reply template for a set of messages'\r
184 >      'show:show all messages matching the search terms'\r
185 >      'tag:add or remove tags for all messages matching the search terms'\r
186 > @@ -53,7 +54,14 @@ _notmuch_search()\r
187 >      '--max-threads=[display only the first x threads from the search results]:number of threads to show: ' \\r
188 >      '--first=[omit the first x threads from the search results]:number of threads to omit: ' \\r
189 >      '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \\r
190 > -    '--output=[select what to output]:output:((summary threads messages files tags sender recipients))'\r
191 > +    '--output=[select what to output]:output:((summary threads messages files tags))'\r
192 > +}\r
193 > +\r
194 > +_notmuch_address()\r
195 > +{\r
196 > +  _arguments -s : \\r
197 > +    '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \\r
198 > +    '--output=[select what to output]:output:((sender recipients))'\r
199 >  }\r
200 >  \r
201 >  _notmuch()\r
202 > diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst\r
203 > new file mode 100644\r
204 > index 0000000..8109f11\r
205 > --- /dev/null\r
206 > +++ b/doc/man1/notmuch-address.rst\r
207 > @@ -0,0 +1,99 @@\r
208 > +===============\r
209 > +notmuch-address\r
210 > +===============\r
211 > +\r
212 > +SYNOPSIS\r
213 > +========\r
214 > +\r
215 > +**notmuch** **address** [*option* ...] <*search-term*> ...\r
216 > +\r
217 > +DESCRIPTION\r
218 > +===========\r
219 > +\r
220 > +Search for messages matching the given search terms, and display the\r
221 > +addresses from them.\r
222 > +\r
223 > +See **notmuch-search-terms(7)** for details of the supported syntax for\r
224 > +<search-terms>.\r
225 > +\r
226 > +Supported options for **address** include\r
227 > +\r
228 > +    ``--format=``\ (**json**\ \|\ **sexp**\ \|\ **text**\ \|\ **text0**)\r
229 > +        Presents the results in either JSON, S-Expressions, newline\r
230 > +        character separated plain-text (default), or null character\r
231 > +        separated plain-text (compatible with **xargs(1)** -0 option\r
232 > +        where available).\r
233 > +\r
234 > +    ``--format-version=N``\r
235 > +        Use the specified structured output format version. This is\r
236 > +        intended for programs that invoke **notmuch(1)** internally. If\r
237 > +        omitted, the latest supported version will be used.\r
238 > +\r
239 > +    ``--output=(sender|recipients)``\r
240 > +\r
241 > +        Controls which information appears in the output. This option\r
242 > +     can be given multiple times to combine different outputs.\r
243 > +     Omitting this option is equivalent to\r
244 > +     --output=sender --output=recipients.\r
245 > +\r
246 > +     **sender**\r
247 > +            Output all addresses from the *From* header.\r
248 > +\r
249 > +         Note: Searching for **sender** should be much faster than\r
250 > +         searching for **recipients**, because sender addresses are\r
251 > +         cached directly in the database whereas other addresses\r
252 > +         need to be fetched from message files.\r
253 > +\r
254 > +     **recipients**\r
255 > +            Output all addresses from the *To*, *Cc* and *Bcc*\r
256 > +            headers.\r
257 > +\r
258 > +    ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
259 > +        This option can be used to present results in either\r
260 > +        chronological order (**oldest-first**) or reverse chronological\r
261 > +        order (**newest-first**).\r
262 > +\r
263 > +        By default, results will be displayed in reverse chronological\r
264 > +        order, (that is, the newest results will be displayed first).\r
265 > +\r
266 > +    ``--exclude=(true|false|all|flag)``\r
267 > +        A message is called "excluded" if it matches at least one tag in\r
268 > +        search.tag\_exclude that does not appear explicitly in the\r
269 > +        search terms. This option specifies whether to omit excluded\r
270 > +        messages in the search process.\r
271 > +\r
272 > +        The default value, **true**, prevents excluded messages from\r
273 > +        matching the search terms.\r
274 > +\r
275 > +        **all** additionally prevents excluded messages from appearing\r
276 > +        in displayed results, in effect behaving as though the excluded\r
277 > +        messages do not exist.\r
278 > +\r
279 > +        **false** allows excluded messages to match search terms and\r
280 > +        appear in displayed results. Excluded messages are still marked\r
281 > +        in the relevant outputs.\r
282 > +\r
283 > +        **flag** only has an effect when ``--output=summary``. The\r
284 > +        output is almost identical to **false**, but the "match count"\r
285 > +        is the number of matching non-excluded messages in the thread,\r
286 > +        rather than the number of matching messages.\r
287 \r
288 The exclude text needs updating as flag makes no sense for the address\r
289 command. \r
290 \r
291 Best wishes \r
292 \r
293 Mark\r
294 \r
295 > +EXIT STATUS\r
296 > +===========\r
297 > +\r
298 > +This command supports the following special exit status codes\r
299 > +\r
300 > +``20``\r
301 > +    The requested format version is too old.\r
302 > +\r
303 > +``21``\r
304 > +    The requested format version is too new.\r
305 > +\r
306 > +SEE ALSO\r
307 > +========\r
308 > +\r
309 > +**notmuch(1)**, **notmuch-config(1)**, **notmuch-count(1)**,\r
310 > +**notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,\r
311 > +**notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,\r
312 > +**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**,\r
313 > +***notmuch-search(1)**\r
314 > diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst\r
315 > index 8110086..65df288 100644\r
316 > --- a/doc/man1/notmuch-search.rst\r
317 > +++ b/doc/man1/notmuch-search.rst\r
318 > @@ -78,25 +78,8 @@ Supported options for **search** include\r
319 >              by null characters (--format=text0), as a JSON array\r
320 >              (--format=json), or as an S-Expression list (--format=sexp).\r
321 >  \r
322 > -     **sender**\r
323 > -            Output all addresses from the *From* header that appear on\r
324 > -            any message matching the search terms, either one per line\r
325 > -            (--format=text), separated by null characters\r
326 > -            (--format=text0), as a JSON array (--format=json), or as\r
327 > -            an S-Expression list (--format=sexp).\r
328 > -\r
329 > -         Note: Searching for **sender** should be much faster than\r
330 > -         searching for **recipients**, because sender addresses are\r
331 > -         cached directly in the database whereas other addresses\r
332 > -         need to be fetched from message files.\r
333 > -\r
334 > -     **recipients**\r
335 > -            Like **sender** but for addresses from *To*, *Cc* and\r
336 > -         *Bcc* headers.\r
337 > -\r
338 >       This option can be given multiple times to combine different\r
339 > -     outputs. Currently, this is only supported for **sender** and\r
340 > -     **recipients** outputs.\r
341 > +     outputs.\r
342 >  \r
343 >      ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
344 >          This option can be used to present results in either\r
345 > @@ -173,3 +156,4 @@ SEE ALSO\r
346 >  **notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,\r
347 >  **notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,\r
348 >  **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**\r
349 > +***notmuch-address(1)**\r
350 > diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst\r
351 > index 9710294..98590a4 100644\r
352 > --- a/doc/man1/notmuch.rst\r
353 > +++ b/doc/man1/notmuch.rst\r
354 > @@ -88,8 +88,8 @@ Several of the notmuch commands accept search terms with a common\r
355 >  syntax. See **notmuch-search-terms**\ (7) for more details on the\r
356 >  supported syntax.\r
357 >  \r
358 > -The **search**, **show** and **count** commands are used to query the\r
359 > -email database.\r
360 > +The **search**, **show**, **address** and **count** commands are used\r
361 > +to query the email database.\r
362 >  \r
363 >  The **reply** command is useful for preparing a template for an email\r
364 >  reply.\r
365 > @@ -128,7 +128,8 @@ SEE ALSO\r
366 >  **notmuch-config(1)**, **notmuch-count(1)**, **notmuch-dump(1)**,\r
367 >  **notmuch-hooks(5)**, **notmuch-insert(1)**, **notmuch-new(1)**,\r
368 >  **notmuch-reply(1)**, **notmuch-restore(1)**, **notmuch-search(1)**,\r
369 > -**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**\r
370 > +**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**,\r
371 > +***notmuch-address(1)**\r
372 >  \r
373 >  The notmuch website: **http://notmuchmail.org**\r
374 >  \r
375 > diff --git a/notmuch-client.h b/notmuch-client.h\r
376 > index e1efbe0..5e0d475 100644\r
377 > --- a/notmuch-client.h\r
378 > +++ b/notmuch-client.h\r
379 > @@ -199,6 +199,9 @@ int\r
380 >  notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]);\r
381 >  \r
382 >  int\r
383 > +notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]);\r
384 > +\r
385 > +int\r
386 >  notmuch_setup_command (notmuch_config_t *config, int argc, char *argv[]);\r
387 >  \r
388 >  int\r
389 > diff --git a/notmuch-search.c b/notmuch-search.c\r
390 > index f115359..cbd84f5 100644\r
391 > --- a/notmuch-search.c\r
392 > +++ b/notmuch-search.c\r
393 > @@ -23,17 +23,18 @@\r
394 >  #include "string-util.h"\r
395 >  \r
396 >  typedef enum {\r
397 > +    /* Search command */\r
398 >      OUTPUT_SUMMARY   = 1 << 0,\r
399 >      OUTPUT_THREADS   = 1 << 1,\r
400 >      OUTPUT_MESSAGES  = 1 << 2,\r
401 >      OUTPUT_FILES     = 1 << 3,\r
402 >      OUTPUT_TAGS              = 1 << 4,\r
403 > +\r
404 > +    /* Address command */\r
405 >      OUTPUT_SENDER    = 1 << 5,\r
406 >      OUTPUT_RECIPIENTS        = 1 << 6,\r
407 >  } output_t;\r
408 >  \r
409 > -#define OUTPUT_ADDRESS_FLAGS (OUTPUT_SENDER | OUTPUT_RECIPIENTS)\r
410 > -\r
411 >  typedef enum {\r
412 >      NOTMUCH_FORMAT_JSON,\r
413 >      NOTMUCH_FORMAT_TEXT,\r
414 > @@ -554,51 +555,55 @@ _notmuch_search_cleanup (search_context_t *ctx)\r
415 >      talloc_free (ctx->format);\r
416 >  }\r
417 >  \r
418 > +static search_context_t search_context = {\r
419 > +    .format_sel = NOTMUCH_FORMAT_TEXT,\r
420 > +    .exclude = NOTMUCH_EXCLUDE_TRUE,\r
421 > +    .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
422 > +    .output = 0,\r
423 > +    .offset = 0,\r
424 > +    .limit = -1, /* unlimited */\r
425 > +    .dupe = -1,\r
426 > +};\r
427 > +\r
428 > +static const notmuch_opt_desc_t common_options[] = {\r
429 > +    { NOTMUCH_OPT_KEYWORD, &search_context.sort, "sort", 's',\r
430 > +      (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
431 > +                           { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
432 > +                           { 0, 0 } } },\r
433 > +    { NOTMUCH_OPT_KEYWORD, &search_context.format_sel, "format", 'f',\r
434 > +      (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
435 > +                           { "sexp", NOTMUCH_FORMAT_SEXP },\r
436 > +                           { "text", NOTMUCH_FORMAT_TEXT },\r
437 > +                           { "text0", NOTMUCH_FORMAT_TEXT0 },\r
438 > +                           { 0, 0 } } },\r
439 > +    { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },\r
440 > +    { NOTMUCH_OPT_KEYWORD, &search_context.exclude, "exclude", 'x',\r
441 > +      (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
442 > +                           { "false", NOTMUCH_EXCLUDE_FALSE },\r
443 > +                           { "flag", NOTMUCH_EXCLUDE_FLAG },\r
444 > +                           { "all", NOTMUCH_EXCLUDE_ALL },\r
445 > +                           { 0, 0 } } },\r
446 > +    { 0, 0, 0, 0, 0 }\r
447 > +};\r
448 > +\r
449 >  int\r
450 >  notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
451 >  {\r
452 > -    search_context_t search_context = {\r
453 > -     .format_sel = NOTMUCH_FORMAT_TEXT,\r
454 > -     .exclude = NOTMUCH_EXCLUDE_TRUE,\r
455 > -     .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
456 > -     .output = 0,\r
457 > -     .offset = 0,\r
458 > -     .limit = -1, /* unlimited */\r
459 > -     .dupe = -1,\r
460 > -    };\r
461 >      search_context_t *ctx = &search_context;\r
462 >      int opt_index, ret;\r
463 >  \r
464 >      notmuch_opt_desc_t options[] = {\r
465 > -     { NOTMUCH_OPT_KEYWORD, &ctx->sort, "sort", 's',\r
466 > -       (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
467 > -                               { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
468 > -                               { 0, 0 } } },\r
469 > -     { NOTMUCH_OPT_KEYWORD, &ctx->format_sel, "format", 'f',\r
470 > -       (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
471 > -                               { "sexp", NOTMUCH_FORMAT_SEXP },\r
472 > -                               { "text", NOTMUCH_FORMAT_TEXT },\r
473 > -                               { "text0", NOTMUCH_FORMAT_TEXT0 },\r
474 > -                               { 0, 0 } } },\r
475 > -     { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },\r
476 >       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
477 >         (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
478 >                                 { "threads", OUTPUT_THREADS },\r
479 >                                 { "messages", OUTPUT_MESSAGES },\r
480 > -                               { "sender", OUTPUT_SENDER },\r
481 > -                               { "recipients", OUTPUT_RECIPIENTS },\r
482 >                                 { "files", OUTPUT_FILES },\r
483 >                                 { "tags", OUTPUT_TAGS },\r
484 >                                 { 0, 0 } } },\r
485 > -        { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',\r
486 > -          (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
487 > -                                  { "false", NOTMUCH_EXCLUDE_FALSE },\r
488 > -                                  { "flag", NOTMUCH_EXCLUDE_FLAG },\r
489 > -                                  { "all", NOTMUCH_EXCLUDE_ALL },\r
490 > -                                  { 0, 0 } } },\r
491 >       { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },\r
492 >       { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0  },\r
493 >       { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0  },\r
494 > +     { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },\r
495 >       { 0, 0, 0, 0, 0 }\r
496 >      };\r
497 >  \r
498 > @@ -623,8 +628,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
499 >       ctx->output == OUTPUT_THREADS)\r
500 >       ret = do_search_threads (ctx);\r
501 >      else if (ctx->output == OUTPUT_MESSAGES ||\r
502 > -          ctx->output == OUTPUT_FILES ||\r
503 > -          (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
504 > +          ctx->output == OUTPUT_FILES)\r
505 >       ret = do_search_messages (ctx);\r
506 >      else if (ctx->output == OUTPUT_TAGS)\r
507 >       ret = do_search_tags (ctx);\r
508 > @@ -637,3 +641,36 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
509 >  \r
510 >      return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
511 >  }\r
512 > +\r
513 > +int\r
514 > +notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
515 > +{\r
516 > +    search_context_t *ctx = &search_context;\r
517 > +    int opt_index, ret;\r
518 > +\r
519 > +    notmuch_opt_desc_t options[] = {\r
520 > +     { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
521 > +       (notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },\r
522 > +                               { "recipients", OUTPUT_RECIPIENTS },\r
523 > +                               { 0, 0 } } },\r
524 > +     { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },\r
525 > +     { 0, 0, 0, 0, 0 }\r
526 > +    };\r
527 > +\r
528 > +    opt_index = parse_arguments (argc, argv, options, 1);\r
529 > +    if (opt_index < 0)\r
530 > +     return EXIT_FAILURE;\r
531 > +\r
532 > +    if (! ctx->output)\r
533 > +     search_context.output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;\r
534 > +\r
535 > +    if (_notmuch_search_prepare (ctx, config,\r
536 > +                              argc - opt_index, argv + opt_index))\r
537 > +     return EXIT_FAILURE;\r
538 > +\r
539 > +    ret = do_search_messages (ctx);\r
540 > +\r
541 > +    _notmuch_search_cleanup (ctx);\r
542 > +\r
543 > +    return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
544 > +}\r
545 > diff --git a/notmuch.c b/notmuch.c\r
546 > index dcda039..0fac099 100644\r
547 > --- a/notmuch.c\r
548 > +++ b/notmuch.c\r
549 > @@ -54,6 +54,8 @@ static command_t commands[] = {\r
550 >        "Add a new message into the maildir and notmuch database." },\r
551 >      { "search", notmuch_search_command, FALSE,\r
552 >        "Search for messages matching the given search terms." },\r
553 > +    { "address", notmuch_address_command, FALSE,\r
554 > +      "Get addresses from messages matching the given search terms." },\r
555 >      { "show", notmuch_show_command, FALSE,\r
556 >        "Show all messages matching the search terms." },\r
557 >      { "count", notmuch_count_command, FALSE,\r
558 > -- \r
559 > 2.1.1\r
560 >\r
561 > _______________________________________________\r
562 > notmuch mailing list\r
563 > notmuch@notmuchmail.org\r
564 > http://notmuchmail.org/mailman/listinfo/notmuch\r