[PATCH 6/7] cli: omit excluded messages in results where appropriate.
authorMark Walters <markwalters1009@gmail.com>
Sun, 29 Jan 2012 18:39:53 +0000 (18:39 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:31 +0000 (09:43 -0800)
2c/59ab791d7842d9e8401e89008a04214ce80a1b [new file with mode: 0644]

diff --git a/2c/59ab791d7842d9e8401e89008a04214ce80a1b b/2c/59ab791d7842d9e8401e89008a04214ce80a1b
new file mode 100644 (file)
index 0000000..c2640b8
--- /dev/null
@@ -0,0 +1,142 @@
+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 81F45429E43\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39: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 6Nor93+8B2Nc for <notmuch@notmuchmail.org>;\r
+       Sun, 29 Jan 2012 10:39:29 -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 97ACC429E3F\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:29 -0800 (PST)\r
+Received: by mail-wi0-f181.google.com with SMTP id hi8so2994807wib.26\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 10:39:29 -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=uughHLUXJgckjirIO48Yw/vn1iM6lHSYqUPlbZNrG6Y=;\r
+       b=xPSRPW1Ut5/jZb8X1uITUR/elqOu6TgWe2nQ7y9P7Q8kXCNoqRm8cMajGOI4vG83iv\r
+       gKrzywu9Mu9lwqL9o3zjiav3bojmbpM/EEim1IldlaQlj9owA1QjdoEskgnVCKBjLLQf\r
+       y4+k6R0+M7wb+TCvCcBWm9etxkVACkpvfBcoI=\r
+Received: by 10.180.89.71 with SMTP id bm7mr18753053wib.20.1327862369324;\r
+       Sun, 29 Jan 2012 10:39:29 -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
+ fv6sm44584373wib.8.2012.01.29.10.39.27        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 29 Jan 2012 10:39:28 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+       amdragon@MIT.EDU\r
+Subject: [PATCH 6/7] cli: omit excluded messages in results where appropriate.\r
+Date: Sun, 29 Jan 2012 18:39:53 +0000\r
+Message-Id: <1327862394-14334-6-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <8762fu4aqt.fsf@qmul.ac.uk>\r
+References: <8762fu4aqt.fsf@qmul.ac.uk>\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, 29 Jan 2012 18:39: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
+--do-not-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   |    5 +++++\r
+ 3 files changed, 16 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index c88975e..1aa3f1a 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -87,6 +87,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 084dd05..339ce82 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 681827f..5d98724 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1167,6 +1167,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 (mbox)\r
++      notmuch_query_set_omit_excluded_messages (query, TRUE);\r
++\r
+     /* if part was requested and format was not specified, use format=raw */\r
+     if (params.part >= 0 && !format_specified)\r
+       format = &format_raw;\r
+-- \r
+1.7.2.3\r
+\r