From 0e918748262205fac4800fa7cd0f2ba90c32617e Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 15 Feb 2012 09:03:35 +0000 Subject: [PATCH] [RFC PATCH v5 07/11] cli: Make notmuch-show respect excludes. --- a7/09b1abed94c943a5ed820adbb7125647d91881 | 143 ++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 a7/09b1abed94c943a5ed820adbb7125647d91881 diff --git a/a7/09b1abed94c943a5ed820adbb7125647d91881 b/a7/09b1abed94c943a5ed820adbb7125647d91881 new file mode 100644 index 000000000..dbb9d4a27 --- /dev/null +++ b/a7/09b1abed94c943a5ed820adbb7125647d91881 @@ -0,0 +1,143 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id B3A6141ED83 + for ; Wed, 15 Feb 2012 01:03:17 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id exFfinDq4B5Q for ; + Wed, 15 Feb 2012 01:03:16 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D442841ED7D + for ; Wed, 15 Feb 2012 01:03:10 -0800 (PST) +Received: by mail-wi0-f181.google.com with SMTP id hi8so453259wib.26 + for ; Wed, 15 Feb 2012 01:03:10 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=KwGuv2DPIrD1wJHtGp0d6TK/okOoXyvJNKYPLe6U0so=; + b=XSYkohWo4/qek2HLqUcex8qw0i9C5ohQ4T5bAxwpXoRX4ON9VbyOabHSMuVcP40OVP + x/siSwritA/gQWnGDFAvPtJ0YhqNZ3GNPLWQQQaNdvgmeNE4BLaW86fh+SvdIHwI1MV6 + cxy4ImhHaZiatXIPcPgaE2dz5xO6/bk7KEDT4= +Received: by 10.180.89.71 with SMTP id bm7mr6991120wib.20.1329296590590; + Wed, 15 Feb 2012 01:03:10 -0800 (PST) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + m16sm7639463wie.9.2012.02.15.01.03.09 (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 15 Feb 2012 01:03:09 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [RFC PATCH v5 07/11] cli: Make notmuch-show respect excludes. +Date: Wed, 15 Feb 2012 09:03:35 +0000 +Message-Id: <1329296619-7463-8-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <1329296619-7463-1-git-send-email-markwalters1009@gmail.com> +References: <1329296619-7463-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 15 Feb 2012 09:03:18 -0000 + +This adds the excludes to notmuch-show.c. We do not exclude when only +a single message (or part) is requested. notmuch-show will output the +exclude information when either text or json format is requested. As +this changes the output from notmuch-show it breaks many tests (in a +trivial and expected fashion). +--- + notmuch-show.c | 25 +++++++++++++++++++++---- + 1 files changed, 21 insertions(+), 4 deletions(-) + +diff --git a/notmuch-show.c b/notmuch-show.c +index d930f94..2a634e9 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -179,9 +179,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in + date = notmuch_message_get_date (message); + relative_date = notmuch_time_relative_date (ctx, date); + +- printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", ++ printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", + json_quote_str (ctx_quote, notmuch_message_get_message_id (message)), + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false", ++ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false", + json_quote_str (ctx_quote, notmuch_message_get_filename (message)), + date, relative_date); + +@@ -735,11 +736,12 @@ format_part_text (const void *ctx, mime_node_t *node, + notmuch_message_t *message = node->envelope_file; + + part_type = "message"; +- printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n", ++ printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n", + part_type, + notmuch_message_get_message_id (message), + indent, +- notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH), ++ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0, ++ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0, + notmuch_message_get_filename (message)); + } else { + GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta); +@@ -1034,6 +1036,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + notmuch_show_params_t params = { .part = -1 }; + int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; + notmuch_bool_t verify = FALSE; ++ notmuch_bool_t no_exclude = FALSE; + + notmuch_opt_desc_t options[] = { + { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', +@@ -1046,6 +1049,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, + { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 }, + { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 }, ++ { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 }, + { 0, 0, 0, 0, 0 } + }; + +@@ -1133,10 +1137,23 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + return 1; + } + ++ /* If a single message is requested we do not use search_excludes. */ + if (params.part >= 0) + ret = do_show_single (ctx, query, format, ¶ms); +- else ++ else { ++ if (!no_exclude) { ++ const char **search_exclude_tags; ++ size_t search_exclude_tags_length; ++ unsigned int i; ++ ++ search_exclude_tags = notmuch_config_get_search_exclude_tags ++ (config, &search_exclude_tags_length); ++ for (i = 0; i < search_exclude_tags_length; i++) ++ notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ } + ret = do_show (ctx, query, format, ¶ms); ++ } ++ + + notmuch_query_destroy (query); + notmuch_database_close (notmuch); +-- +1.7.2.3 + -- 2.26.2