[Patch v7 11/13] cli: omit excluded messages in results where appropriate.
authorMark Walters <markwalters1009@gmail.com>
Thu, 1 Mar 2012 22:30:43 +0000 (22:30 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:09 +0000 (09:45 -0800)
6c/7030850c0b274e44c8e302a32f943792d10941 [new file with mode: 0644]

diff --git a/6c/7030850c0b274e44c8e302a32f943792d10941 b/6c/7030850c0b274e44c8e302a32f943792d10941
new file mode 100644 (file)
index 0000000..1bdf566
--- /dev/null
@@ -0,0 +1,162 @@
+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 A49E7431FB6\r
+       for <notmuch@notmuchmail.org>; Thu,  1 Mar 2012 14:29:51 -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 mk42MQoN7HKL for <notmuch@notmuchmail.org>;\r
+       Thu,  1 Mar 2012 14:29:50 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ A613D431FDC   for <notmuch@notmuchmail.org>; Thu,  1 Mar 2012 14:29:45 -0800\r
+ (PST)\r
+Received: by mail-ww0-f45.google.com with SMTP id dt12so108365wgb.2\r
+       for <notmuch@notmuchmail.org>; Thu, 01 Mar 2012 14:29:45 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
+       10.180.107.162 as permitted sender) client-ip=10.180.107.162; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+       markwalters1009@gmail.com designates 10.180.107.162 as\r
+       permitted sender) smtp.mail=markwalters1009@gmail.com;\r
+       dkim=pass header.i=markwalters1009@gmail.com\r
+Received: from mr.google.com ([10.180.107.162])\r
+       by 10.180.107.162 with SMTP id hd2mr6562681wib.8.1330640985503\r
+       (num_hops = 1); Thu, 01 Mar 2012 14:29:45 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=9k1rZ+UTk4//KtSpKM8nYisUh4WGv1+3Ifs5+7c+azw=;\r
+       b=Ghk33ggocsAGnJieT9zx50ZJGoBwxxMDcXyaHc4IFSrbK9YVuNRSpj+Mh7PQx5H6Mk\r
+       og7UwuOWR6lhCHSGQEC8pw7lkml5cnoMMqdWsS9bebq+IKEXyt8vn99XwWnampD3bHiF\r
+       hZiV3YuCQxPDVrJc6sAegwAtjpvjvXOhSEx2YFzB1SH8j7G9Y5i4PLYLreVl+xmqXIeT\r
+       5ka7Lt/cg5r0PfCtu3E77N/2vlAos9uta+Ev2TIZmuGJLh7zsIfVMdclPm0kvr5RZXt+\r
+       eeVOx/cDNCnrMjMiLyWJDiLcyHAP5k7h4sma1IcQQ8iuq71KqdMmSljc0hXtTUofRdHs\r
+       M/cA==\r
+Received: by 10.180.107.162 with SMTP id hd2mr5287786wib.8.1330640985449;\r
+       Thu, 01 Mar 2012 14:29:45 -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
+ dr5sm16656885wib.0.2012.03.01.14.29.43        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 01 Mar 2012 14:29:44 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v7 11/13] cli: omit excluded messages in results where\r
+       appropriate.\r
+Date: Thu,  1 Mar 2012 22:30:43 +0000\r
+Message-Id: <1330641045-27416-12-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1330641045-27416-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1330641045-27416-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: Thu, 01 Mar 2012 22:29:52 -0000\r
+\r
+In all cases of notmuch count/search/show where the results returned\r
+cannot reflect the exclude flag return just the matched not-excluded\r
+results. If the caller wishes to have all the matched results (i.e.,\r
+including the excluded ones) they should call with the\r
+--no-exclude option.\r
+\r
+The relevant cases are\r
+    count: both threads and messages\r
+    search: all cases except the summary view\r
+    show: mbox format\r
+---\r
+ notmuch-count.c  |    2 ++\r
+ notmuch-search.c |    9 +++++++++\r
+ notmuch-show.c   |    6 ++++++\r
+ 3 files changed, 17 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 5364507..46b76ae 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -88,6 +88,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
+     }\r
+ \r
++    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+     switch (output) {\r
+     case OUTPUT_MESSAGES:\r
+       printf ("%u\n", notmuch_query_count_messages (query));\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 6d6c0e6..f6061e4 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -210,6 +210,9 @@ do_search_threads (const search_format_t *format,\r
+     int first_thread = 1;\r
+     int i;\r
+ \r
++    if (output == OUTPUT_THREADS)\r
++      notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+     if (offset < 0) {\r
+       offset += notmuch_query_count_threads (query);\r
+       if (offset < 0)\r
+@@ -300,6 +303,8 @@ do_search_messages (const search_format_t *format,\r
+     int first_message = 1;\r
+     int i;\r
+ \r
++    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+     if (offset < 0) {\r
+       offset += notmuch_query_count_messages (query);\r
+       if (offset < 0)\r
+@@ -371,6 +376,10 @@ do_search_tags (notmuch_database_t *notmuch,\r
+     const char *tag;\r
+     int first_tag = 1;\r
+ \r
++    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++    /* should the following only special case if no excluded terms\r
++     * specified? */\r
++\r
+     /* Special-case query of "*" for better performance. */\r
+     if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {\r
+       tags = notmuch_database_get_all_tags (notmuch);\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 8c0b925..05d51b2 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1030,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+           fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");\r
+           return 1;\r
+       }\r
++\r
+       format = &format_mbox;\r
+       break;\r
+     case NOTMUCH_FORMAT_RAW:\r
+@@ -1087,6 +1088,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+       return 1;\r
+     }\r
+ \r
++    /* if format=mbox then we can not output excluded messages as\r
++     * there is no way to make the exclude flag available */\r
++    if (format_sel == NOTMUCH_FORMAT_MBOX)\r
++      notmuch_query_set_omit_excluded_messages (query, TRUE);\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
+-- \r
+1.7.2.3\r
+\r