[WIP 2/2] cli: add --exclude=all option to notmuch-search.c
authorMark Walters <markwalters1009@gmail.com>
Sun, 17 Jun 2012 07:27:26 +0000 (08:27 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:42 +0000 (09:47 -0800)
16/5374cc32162736335836c2a8b621e050e66483 [new file with mode: 0644]

diff --git a/16/5374cc32162736335836c2a8b621e050e66483 b/16/5374cc32162736335836c2a8b621e050e66483
new file mode 100644 (file)
index 0000000..a4b711c
--- /dev/null
@@ -0,0 +1,130 @@
+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 08D11431FBC\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Jun 2012 00:27:53 -0700 (PDT)\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 JIPVEl9rz1hh for <notmuch@notmuchmail.org>;\r
+       Sun, 17 Jun 2012 00:27:50 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 6289F431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Jun 2012 00:27:50 -0700 (PDT)\r
+Received: by werj55 with SMTP id j55so3608086wer.26\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Jun 2012 00:27:49 -0700 (PDT)\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=LCmNXoe3ZZ0LJgIv/Ryq12m/DW9HIGmad2nEMTn2WT8=;\r
+       b=s1J7lJMzYi8blB4UNFnF3ZH0jacSXnbPmA+HYE7Z4bkT7ZzjtCo33xd1K5XWqruAT5\r
+       KTDlSIN2DMKn+xhyHyTlHIY/y/vneXhlr/JaTf02Fe7yluALlfvhx+1AAaRP5XV5s21p\r
+       ADkM71OQbAKZkK5cuvAqXGouz3odmlu2zOg31VwPbJGxy+aKaWnVnLRNY9U5winu3Rmv\r
+       y5TrhV34CR6M9lFo+LmHqBX/MvD/tGdyauKbeMCDe2XuohrehDymBrNVxVprOB9dtZId\r
+       LeFoXEW+Xp2FsLA7xfbshCXrcYIMTJ1LQjuF24oiWbERHJ1IgDJng94fjOlyjmxOgC8P\r
+       qgCg==\r
+Received: by 10.216.30.195 with SMTP id k45mr5892337wea.40.1339918068773;\r
+       Sun, 17 Jun 2012 00:27:48 -0700 (PDT)\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
+ gb9sm16419953wib.8.2012.06.17.00.27.47        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 17 Jun 2012 00:27:48 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+       novalazy@gmail.com\r
+Subject: [WIP 2/2] cli: add --exclude=all option to notmuch-search.c\r
+Date: Sun, 17 Jun 2012 08:27:26 +0100\r
+Message-Id: <1339918046-3448-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1339918046-3448-1-git-send-email-markwalters1009@gmail.com>\r
+References: <87zk82l7wp.fsf@qmul.ac.uk>\r
+       <1339918046-3448-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, 17 Jun 2012 07:27:53 -0000\r
+\r
+Add a --exclude=all option to notmuch search.\r
+\r
+---\r
+ notmuch-search.c |    8 ++++++--\r
+ test/excludes    |    5 +++++\r
+ 2 files changed, 11 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 3be296d..89b5bf9 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -420,6 +420,7 @@ enum {\r
+     EXCLUDE_TRUE,\r
+     EXCLUDE_FALSE,\r
+     EXCLUDE_FLAG,\r
++    EXCLUDE_ALL\r
+ };\r
+ \r
+ int\r
+@@ -461,6 +462,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+           (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
+                                   { "false", EXCLUDE_FALSE },\r
+                                   { "flag", EXCLUDE_FLAG },\r
++                                  { "all", EXCLUDE_ALL },\r
+                                   { 0, 0 } } },\r
+       { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+       { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
+@@ -516,7 +518,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+       exclude = EXCLUDE_FALSE;\r
+     }\r
+ \r
+-    if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) {\r
++    if (exclude != EXCLUDE_FALSE) {\r
+       const char **search_exclude_tags;\r
+       size_t search_exclude_tags_length;\r
+ \r
+@@ -525,7 +527,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+       for (i = 0; i < search_exclude_tags_length; i++)\r
+           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
+       if (exclude == EXCLUDE_FLAG)\r
+-          notmuch_query_set_omit_excluded (query, FALSE);\r
++          notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE);\r
++      if (exclude == EXCLUDE_ALL)\r
++          notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);\r
+     }\r
+ \r
+     switch (output) {\r
+diff --git a/test/excludes b/test/excludes\r
+index 24d653e..7be8d79 100755\r
+--- a/test/excludes\r
++++ b/test/excludes\r
+@@ -166,6 +166,11 @@ ${matching_message_ids[3]}\r
+ ${matching_message_ids[4]}\r
+ ${matching_message_ids[5]}"\r
+ \r
++test_begin_subtest "Search, exclude=all (thread summary)"\r
++output=$(notmuch search --exclude=all tag:test | notmuch_search_sanitize)\r
++test_expect_equal "$output" "thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (inbox test unread)\r
++thread:XXX   2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)"\r
++\r
+ test_begin_subtest "Search, default exclusion: tag in query (thread summary)"\r
+ output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "thread:XXX   2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread)\r
+-- \r
+1.7.9.1\r
+\r