[Patch v6 08/13] cli: Make notmuch-show respect excludes.
authorMark Walters <markwalters1009@gmail.com>
Sat, 25 Feb 2012 08:06:39 +0000 (08:06 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:57 +0000 (09:44 -0800)
6e/f05fecadeff6de2d3aa9fd93568bbd2892b218 [new file with mode: 0644]

diff --git a/6e/f05fecadeff6de2d3aa9fd93568bbd2892b218 b/6e/f05fecadeff6de2d3aa9fd93568bbd2892b218
new file mode 100644 (file)
index 0000000..4f65267
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 988DA431E64\r
+       for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:04:35 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id bRn06gNPYSFW for <notmuch@notmuchmail.org>;\r
+       Sat, 25 Feb 2012 19:04:34 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 935C8416390\r
+       for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:44:55 -0800 (PST)\r
+Received: by wibhi8 with SMTP id hi8so2530505wib.26\r
+       for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:44:54 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
+       10.180.99.7 as permitted sender) client-ip=10.180.99.7; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+       markwalters1009@gmail.com designates 10.180.99.7 as permitted\r
+       sender) smtp.mail=markwalters1009@gmail.com;\r
+       dkim=pass header.i=markwalters1009@gmail.com\r
+Received: from mr.google.com ([10.180.99.7])\r
+       by 10.180.99.7 with SMTP id em7mr17111907wib.7.1330224294455 (num_hops\r
+       = 1); Sat, 25 Feb 2012 18:44:54 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=KwGuv2DPIrD1wJHtGp0d6TK/okOoXyvJNKYPLe6U0so=;\r
+       b=SJEb62fLR40sfOr6P0tEZwWydOea1XM1/Q8zrdOJTpM0nq8MUWknbHCutJRyEWaR18\r
+       dqAX4RzO+2Nkxj2wk6YvxLnus/tKzcUp8XEidt2TiZjbUScJk7hoK/FKpYzp8zKJ+CtW\r
+       0PG7pPf/2eMVZfErs8PdgD89SNKGmZm7FvD7o=\r
+Received: by 10.180.99.7 with SMTP id em7mr9349881wib.7.1330157144348;\r
+       Sat, 25 Feb 2012 00:05:44 -0800 (PST)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ by4sm2316267wib.3.2012.02.25.00.05.43 (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 25 Feb 2012 00:05:43 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+       Austin Clements <amdragon@MIT.EDU>\r
+Subject: [Patch v6 08/13] cli: Make notmuch-show respect excludes.\r
+Date: Sat, 25 Feb 2012 08:06:39 +0000\r
+Message-Id: <1330157204-26094-9-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1330157204-26094-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 26 Feb 2012 03:04:35 -0000\r
+\r
+This adds the excludes to notmuch-show.c. We do not exclude when only\r
+a single message (or part) is requested. notmuch-show will output the\r
+exclude information when either text or json format is requested. As\r
+this changes the output from notmuch-show it breaks many tests (in a\r
+trivial and expected fashion).\r
+---\r
+ notmuch-show.c |   25 +++++++++++++++++++++----\r
+ 1 files changed, 21 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index d930f94..2a634e9 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -179,9 +179,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in\r
+     date = notmuch_message_get_date (message);\r
+     relative_date = notmuch_time_relative_date (ctx, date);\r
+ \r
+-    printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",\r
++    printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",\r
+           json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),\r
+           notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",\r
++          notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",\r
+           json_quote_str (ctx_quote, notmuch_message_get_filename (message)),\r
+           date, relative_date);\r
+ \r
+@@ -735,11 +736,12 @@ format_part_text (const void *ctx, mime_node_t *node,\r
+       notmuch_message_t *message = node->envelope_file;\r
+ \r
+       part_type = "message";\r
+-      printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",\r
++      printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n",\r
+               part_type,\r
+               notmuch_message_get_message_id (message),\r
+               indent,\r
+-              notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),\r
++              notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,\r
++              notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,\r
+               notmuch_message_get_filename (message));\r
+     } else {\r
+       GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta);\r
+@@ -1034,6 +1036,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+     notmuch_show_params_t params = { .part = -1 };\r
+     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
+     notmuch_bool_t verify = FALSE;\r
++    notmuch_bool_t no_exclude = FALSE;\r
+ \r
+     notmuch_opt_desc_t options[] = {\r
+       { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
+@@ -1046,6 +1049,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+       { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },\r
+       { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
+       { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
++      { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },\r
+       { 0, 0, 0, 0, 0 }\r
+     };\r
+ \r
+@@ -1133,10 +1137,23 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+       return 1;\r
+     }\r
+ \r
++    /* If a single message is requested we do not use search_excludes. */\r
+     if (params.part >= 0)\r
+       ret = do_show_single (ctx, query, format, &params);\r
+-    else\r
++    else {\r
++      if (!no_exclude) {\r
++          const char **search_exclude_tags;\r
++          size_t search_exclude_tags_length;\r
++          unsigned int i;\r
++\r
++          search_exclude_tags = notmuch_config_get_search_exclude_tags\r
++              (config, &search_exclude_tags_length);\r
++          for (i = 0; i < search_exclude_tags_length; i++)\r
++              notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
++      }\r
+       ret = do_show (ctx, query, format, &params);\r
++    }\r
++\r
+ \r
+     notmuch_query_destroy (query);\r
+     notmuch_database_close (notmuch);\r
+-- \r
+1.7.2.3\r
+\r