1 Return-Path: <markwalters1009@gmail.com>
\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 AF672431FBD
\r
6 for <notmuch@notmuchmail.org>; Fri, 9 Nov 2012 10:58:28 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id ROQjZyqm58nU for <notmuch@notmuchmail.org>;
\r
18 Fri, 9 Nov 2012 10:58:28 -0800 (PST)
\r
19 Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com
\r
20 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
21 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
22 EB269431FAE for <notmuch@notmuchmail.org>; Fri, 9 Nov 2012 10:58:27 -0800
\r
24 Received: by mail-wg0-f45.google.com with SMTP id dq12so2288423wgb.2
\r
25 for <notmuch@notmuchmail.org>; Fri, 09 Nov 2012 10:58:27 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=6f5Trh6jvu/FRTUCd8oNmPXvKMnpi9AzfQkdRolibGc=;
\r
29 b=EEf9hkoRMYc5NQWzbiLWco3ksHa562jlHqfSf0wlc4mYTRF1y48jwWb6HVMsU/3P5Y
\r
30 /jNezRhqMCMOvY3PQn5UBaRKbq2leC6z6rLmXzWPbRBfn0DRGlWBXrq7gMIb+R6UOYnF
\r
31 7HjiZzC3FRKIiwCwPXeQef3zWfYx6p92uvby+z6RjUoHkwu21stEU4u+rhQT4+JrwMJO
\r
32 0weOUSVZ4f3CcpPOABAHT2lIngD5/kt3gOifTDJpLO8PI4w5tPXB1nS7LrWF1XneX2Oj
\r
33 9A2+RzstBmA5bYkZls1/1lqwlWPPS2dCzyRv+RPDhWJ3dr8Y1LRXllkNhfOJTFMRw2eC
\r
35 Received: by 10.180.102.166 with SMTP id fp6mr4165109wib.9.1352487507604;
\r
36 Fri, 09 Nov 2012 10:58:27 -0800 (PST)
\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
38 by mx.google.com with ESMTPS id gg4sm3767301wib.6.2012.11.09.10.58.26
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Fri, 09 Nov 2012 10:58:26 -0800 (PST)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 2/3] cli: all search mode to include msg-ids with JSON output
\r
44 Date: Fri, 9 Nov 2012 18:58:10 +0000
\r
45 Message-Id: <1352487491-31512-3-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Fri, 09 Nov 2012 18:58:28 -0000
\r
63 This adds a --output=with-ids option which gives similar output to the
\r
64 normal search summary output but with a list of message ids
\r
65 too. Currently this is not implemented for text format.
\r
67 notmuch-search.c | 40 ++++++++++++++++++++++++++++++++++++++--
\r
68 1 files changed, 38 insertions(+), 2 deletions(-)
\r
70 diff --git a/notmuch-search.c b/notmuch-search.c
\r
71 index 830c4e4..82e168c 100644
\r
72 --- a/notmuch-search.c
\r
73 +++ b/notmuch-search.c
\r
74 @@ -26,7 +26,8 @@ typedef enum {
\r
80 + OUTPUT_SUMMARY_WITH_IDS
\r
84 @@ -46,6 +47,23 @@ sanitize_string (const void *ctx, const char *str)
\r
89 +output_msg_ids (sprinter_t *format,
\r
90 + notmuch_bool_t matching,
\r
91 + notmuch_messages_t *messages)
\r
93 + notmuch_message_t *message;
\r
95 + notmuch_messages_valid (messages);
\r
96 + notmuch_messages_move_to_next (messages))
\r
98 + message = notmuch_messages_get (messages);
\r
99 + if (notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) == matching)
\r
100 + format->string (format, notmuch_message_get_message_id (message));
\r
101 + output_msg_ids (format, matching, notmuch_message_get_replies (message));
\r
106 do_search_threads (sprinter_t *format,
\r
107 notmuch_query_t *query,
\r
108 @@ -88,7 +106,7 @@ do_search_threads (sprinter_t *format,
\r
109 format->string (format,
\r
110 notmuch_thread_get_thread_id (thread));
\r
111 format->separator (format);
\r
112 - } else { /* output == OUTPUT_SUMMARY */
\r
113 + } else { /* output == OUTPUT_SUMMARY or OUTPUT_SUMMARY_WITH_IDS */
\r
114 void *ctx_quote = talloc_new (thread);
\r
115 const char *authors = notmuch_thread_get_authors (thread);
\r
116 const char *subject = notmuch_thread_get_subject (thread);
\r
117 @@ -160,6 +178,18 @@ do_search_threads (sprinter_t *format,
\r
120 format->end (format);
\r
122 + if (output == OUTPUT_SUMMARY_WITH_IDS) {
\r
123 + format->map_key (format, "matching_msg_ids");
\r
124 + format->begin_list (format);
\r
125 + output_msg_ids (format, TRUE, notmuch_thread_get_toplevel_messages (thread));
\r
126 + format->end (format);
\r
127 + format->map_key (format, "nonmatching_msg_ids");
\r
128 + format->begin_list (format);
\r
129 + output_msg_ids (format, FALSE, notmuch_thread_get_toplevel_messages (thread));
\r
130 + format->end (format);
\r
133 format->end (format);
\r
134 format->separator (format);
\r
136 @@ -323,6 +353,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
137 { "messages", OUTPUT_MESSAGES },
\r
138 { "files", OUTPUT_FILES },
\r
139 { "tags", OUTPUT_TAGS },
\r
140 + { "with-ids", OUTPUT_SUMMARY_WITH_IDS },
\r
142 { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
\r
143 (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
\r
144 @@ -398,6 +429,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
145 notmuch_query_set_omit_excluded (query, FALSE);
\r
148 + if (output == OUTPUT_SUMMARY_WITH_IDS && format_sel == NOTMUCH_FORMAT_TEXT) {
\r
149 + fprintf (stderr, "Warning: --output=with-ids not implemented for text format.\n");
\r
150 + output = OUTPUT_SUMMARY;
\r
155 case OUTPUT_SUMMARY:
\r