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 67BBB429E43
\r
6 for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:26 -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 z0bT2IWceEUI for <notmuch@notmuchmail.org>;
\r
18 Sun, 29 Jan 2012 10:39:25 -0800 (PST)
\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com
\r
20 [209.85.212.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 942F5429E3F
\r
23 for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:25 -0800 (PST)
\r
24 Received: by mail-wi0-f181.google.com with SMTP id hi8so2994807wib.26
\r
25 for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:25 -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=Vb/vCEGOf9tKHwAE8SRmOis9qs2PnzdN6DbCeqij/EM=;
\r
29 b=CEp/M6qQmPMQnCpgAg08D22p/TX2LYraf4Q12ifizG1PndxTO4KveqExZXgwbjP9Cs
\r
30 TvX17Jl+tVZQcsJ4i4FYOK0B3tYK1I62zKssG/HNG352U1OfpJGuuOy1RhlOyPmJAc4M
\r
31 bH6cqoEAErSYeKbdgVcIBjCPaxpJ55vl+9dGE=
\r
32 Received: by 10.180.77.200 with SMTP id u8mr22886353wiw.18.1327862365310;
\r
33 Sun, 29 Jan 2012 10:39:25 -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 j16sm44636947wie.4.2012.01.29.10.39.23 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Sun, 29 Jan 2012 10:39:24 -0800 (PST)
\r
38 From: Mark Walters <markwalters1009@gmail.com>
\r
39 To: notmuch@notmuchmail.org,
\r
41 Subject: [PATCH 5/7] cli: Make notmuch-show respect excludes.
\r
42 Date: Sun, 29 Jan 2012 18:39:52 +0000
\r
43 Message-Id: <1327862394-14334-5-git-send-email-markwalters1009@gmail.com>
\r
44 X-Mailer: git-send-email 1.7.2.3
\r
45 In-Reply-To: <8762fu4aqt.fsf@qmul.ac.uk>
\r
46 References: <8762fu4aqt.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: Sun, 29 Jan 2012 18:39:26 -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 | 26 +++++++++++++++++++++-----
\r
68 1 files changed, 21 insertions(+), 5 deletions(-)
\r
70 diff --git a/notmuch-show.c b/notmuch-show.c
\r
71 index dec799c..681827f 100644
\r
72 --- a/notmuch-show.c
\r
73 +++ b/notmuch-show.c
\r
74 @@ -193,10 +193,12 @@ _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 + /* Could changing this could break users ? */
\r
80 + printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n",
\r
81 notmuch_message_get_message_id (message),
\r
83 - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
\r
84 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,
\r
85 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
\r
86 notmuch_message_get_filename (message));
\r
89 @@ -212,9 +214,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in
\r
90 date = notmuch_message_get_date (message);
\r
91 relative_date = notmuch_time_relative_date (ctx, date);
\r
93 - printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
94 + printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
\r
95 json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
\r
96 notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
\r
97 + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
\r
98 json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
\r
99 date, relative_date);
\r
101 @@ -1059,9 +1062,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
103 const notmuch_show_format_t *format = &format_text;
\r
104 notmuch_show_params_t params;
\r
105 + const char **search_exclude_tags;
\r
106 + size_t search_exclude_tags_length;
\r
108 int format_specified = 0;
\r
110 + notmuch_bool_t do_not_exclude = FALSE;
\r
113 params.entire_thread = 0;
\r
115 @@ -1098,6 +1105,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
116 params.part = atoi(argv[i] + sizeof ("--part=") - 1);
\r
117 } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {
\r
118 params.entire_thread = 1;
\r
119 + } else if (STRNCMP_LITERAL (argv[i], "--do-not-exclude") == 0) {
\r
120 + do_not_exclude = TRUE;
\r
121 } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||
\r
122 (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
\r
123 if (params.cryptoctx == NULL) {
\r
124 @@ -1105,7 +1114,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
125 /* TODO: GMimePasswordRequestFunc */
\r
126 if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, "gpg")))
\r
128 - GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);
\r
129 + GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);
\r
130 if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg")))
\r
132 fprintf (stderr, "Failed to construct gpg context.\n");
\r
133 @@ -1167,10 +1176,17 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
134 if (params.raw && params.part < 0)
\r
137 + /* if a single message is requested we do not use search_excludes */
\r
138 if (params.part >= 0)
\r
139 return do_show_single (ctx, query, format, ¶ms);
\r
141 - return do_show (ctx, query, format, ¶ms);
\r
142 + if (!do_not_exclude) {
\r
143 + search_exclude_tags = notmuch_config_get_search_exclude_tags
\r
144 + (config, &search_exclude_tags_length);
\r
145 + for (j = 0; j < search_exclude_tags_length; j++)
\r
146 + notmuch_query_add_tag_exclude (query, search_exclude_tags[j]);
\r
147 + return do_show (ctx, query, format, ¶ms);
\r
150 notmuch_query_destroy (query);
\r
151 notmuch_database_close (notmuch);
\r