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 0DE1F431FDB
\r
6 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:37 -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 vPndkAPI61yO for <notmuch@notmuchmail.org>;
\r
18 Thu, 2 Feb 2012 09:43:34 -0800 (PST)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 450AC429E26
\r
23 for <notmuch@notmuchmail.org>; Thu, 2 Feb 2012 09:43:13 -0800 (PST)
\r
24 Received: by mail-we0-f181.google.com with SMTP id b10so2324200wer.26
\r
25 for <notmuch@notmuchmail.org>; Thu, 02 Feb 2012 09:43:12 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=sw+JxQaFNuQXW0Jf7pM157lQjP54/aRZ6ne3aqKuvZQ=;
\r
29 b=JutaeZubeDzqgO3Rp+BqO3Tyz+XiaLbxeM3P3i20xmYSdY+ujeYR8XVtxJQnEaw+vu
\r
30 QE+/H/opxhmpP++OE5ndXoDovBOe3gWeO95lWNTkFoN2YzeAHF2nGqslYNDpZVWeGeyf
\r
31 LtAcJN41DoBTydCz0/Enl5tf4eAdHM7/5u7Gk=
\r
32 Received: by 10.216.134.39 with SMTP id r39mr4871806wei.50.1328204592914;
\r
33 Thu, 02 Feb 2012 09:43:12 -0800 (PST)
\r
34 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
35 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
36 l8sm9146585wiy.5.2012.02.02.09.43.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu,
\r
37 02 Feb 2012 09:43:11 -0800 (PST)
\r
38 From: Mark Walters <markwalters1009@gmail.com>
\r
39 To: notmuch@notmuchmail.org,
\r
41 Subject: [PATCH v4 08/11] cli: Make notmuch-show respect excludes.
\r
42 Date: Thu, 2 Feb 2012 17:43:36 +0000
\r
43 Message-Id: <1328204619-25046-8-git-send-email-markwalters1009@gmail.com>
\r
44 X-Mailer: git-send-email 1.7.2.3
\r
45 In-Reply-To: <874nv9rv79.fsf@qmul.ac.uk>
\r
46 References: <874nv9rv79.fsf@qmul.ac.uk>
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Thu, 02 Feb 2012 17:43:37 -0000
\r
61 This adds the excludes to notmuch-show.c. We do not exclude when only
\r
62 a single message (or part) is requested. notmuch-show will output the
\r
63 exclude information when either text or json format is requested. As
\r
64 this changes the output from notmuch-show it breaks many tests (in a
\r
65 trivial and expected fashion).
\r
67 notmuch-show.c | 24 ++++++++++++++++++++----
\r
68 1 files changed, 20 insertions(+), 4 deletions(-)
\r
70 diff --git a/notmuch-show.c b/notmuch-show.c
\r
71 index dec799c..108f13b 100644
\r
72 --- a/notmuch-show.c
\r
73 +++ b/notmuch-show.c
\r
74 @@ -193,10 +193,11 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
76 format_message_text (unused (const void *ctx), notmuch_message_t *message, int indent)
\r
78 - printf ("id:%s depth:%d match:%d filename:%s\n",
\r
79 + printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n",
\r
80 notmuch_message_get_message_id (message),
\r
82 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
\r
83 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,
\r
84 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
\r
85 notmuch_message_get_filename (message));
\r
88 @@ -212,9 +213,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in
\r
89 date = notmuch_message_get_date (message);
\r
90 relative_date = notmuch_time_relative_date (ctx, date);
\r
92 - printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
93 + printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
94 json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
95 notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
96 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
97 json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
98 date, relative_date);
\r
100 @@ -1059,9 +1061,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
102 const notmuch_show_format_t *format = &format_text;
\r
103 notmuch_show_params_t params;
\r
104 + const char **search_exclude_tags;
\r
105 + size_t search_exclude_tags_length;
\r
107 int format_specified = 0;
\r
109 + notmuch_bool_t no_exclude = FALSE;
\r
112 params.entire_thread = 0;
\r
114 @@ -1098,6 +1104,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
115 params.part = atoi(argv[i] + sizeof ("--part=") - 1);
\r
116 } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {
\r
117 params.entire_thread = 1;
\r
118 + } else if (STRNCMP_LITERAL (argv[i], "--no-exclude") == 0) {
\r
119 + no_exclude = TRUE;
\r
120 } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||
\r
121 (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
\r
122 if (params.cryptoctx == NULL) {
\r
123 @@ -1167,10 +1175,18 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
124 if (params.raw && params.part < 0)
\r
127 + /* If a single message is requested we do not use search_excludes. */
\r
128 if (params.part >= 0)
\r
129 return do_show_single (ctx, query, format, ¶ms);
\r
132 + if (!no_exclude) {
\r
133 + search_exclude_tags = notmuch_config_get_search_exclude_tags
\r
134 + (config, &search_exclude_tags_length);
\r
135 + for (j = 0; j < search_exclude_tags_length; j++)
\r
136 + notmuch_query_add_tag_exclude (query, search_exclude_tags[j]);
\r
138 return do_show (ctx, query, format, ¶ms);
\r
141 notmuch_query_destroy (query);
\r
142 notmuch_database_close (notmuch);
\r