[Patch v6 11/13] cli: omit excluded messages in results where appropriate.
authorMark Walters <markwalters1009@gmail.com>
Sat, 25 Feb 2012 08:06:42 +0000 (08:06 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:57 +0000 (09:44 -0800)
be/5a703a810ccc23921ffecf450f6ee0bf7b2905 [new file with mode: 0644]

diff --git a/be/5a703a810ccc23921ffecf450f6ee0bf7b2905 b/be/5a703a810ccc23921ffecf450f6ee0bf7b2905
new file mode 100644 (file)
index 0000000..b08cb98
--- /dev/null
@@ -0,0 +1,160 @@
+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 8FF75429E54\r
+       for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 19:07:30 -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 PSKCk53cUydo for <notmuch@notmuchmail.org>;\r
+       Sat, 25 Feb 2012 19:07:29 -0800 (PST)\r
+Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com\r
+ [74.125.82.41])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 24D2341806C   for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:50:54 -0800\r
+ (PST)\r
+Received: by wgbds1 with SMTP id ds1so230173wgb.2\r
+       for <notmuch@notmuchmail.org>; Sat, 25 Feb 2012 18:50:51 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
+       10.180.107.169 as permitted sender) client-ip=10.180.107.169; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+       markwalters1009@gmail.com designates 10.180.107.169 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.169])\r
+       by 10.180.107.169 with SMTP id hd9mr7283065wib.0.1330224651743\r
+       (num_hops = 1); Sat, 25 Feb 2012 18:50:51 -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=SMyRo6NKb+fBzZo1Wm85RVSEOlk9yEp6ESwsayulzUk=;\r
+       b=OC99sSEZXNI0TWCPDbs/diYS3owuWxupKK1OWjdW2lHWlrca348z4pP7NtJqZMsUt3\r
+       24DV0dMbAOd4/OMiGH6dWBkkRePHjcVUkITIuqaDOqqYED9Yu3kuz8P0OAt88e9WleKu\r
+       SyxwfCYcW+DBmDqTqHtBpJAIzm5o1iPB/ap3Y=\r
+Received: by 10.180.107.169 with SMTP id hd9mr1481257wib.0.1330157151673;\r
+       Sat, 25 Feb 2012 00:05:51 -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
+ h19sm8198804wiw.9.2012.02.25.00.05.50 (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 25 Feb 2012 00:05:51 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+       Austin Clements <amdragon@MIT.EDU>\r
+Subject: [Patch v6 11/13] cli: omit excluded messages in results where\r
+       appropriate.\r
+Date: Sat, 25 Feb 2012 08:06:42 +0000\r
+Message-Id: <1330157204-26094-12-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:07:30 -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 d1c5553..61c65e5 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -207,6 +207,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
+@@ -297,6 +300,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
+@@ -368,6 +373,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 2a634e9..17a4ec6 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1080,6 +1080,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
+@@ -1137,6 +1138,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