From 08cc931cccc107c6a8c58bcb86aade0904ec2332 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 17 Jun 2012 08:27:26 +0100 Subject: [PATCH] [WIP 2/2] cli: add --exclude=all option to notmuch-search.c --- 16/5374cc32162736335836c2a8b621e050e66483 | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 16/5374cc32162736335836c2a8b621e050e66483 diff --git a/16/5374cc32162736335836c2a8b621e050e66483 b/16/5374cc32162736335836c2a8b621e050e66483 new file mode 100644 index 000000000..a4b711cf3 --- /dev/null +++ b/16/5374cc32162736335836c2a8b621e050e66483 @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 08D11431FBC + for ; Sun, 17 Jun 2012 00:27:53 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id JIPVEl9rz1hh for ; + Sun, 17 Jun 2012 00:27:50 -0700 (PDT) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 6289F431FAE + for ; Sun, 17 Jun 2012 00:27:50 -0700 (PDT) +Received: by werj55 with SMTP id j55so3608086wer.26 + for ; Sun, 17 Jun 2012 00:27:49 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=LCmNXoe3ZZ0LJgIv/Ryq12m/DW9HIGmad2nEMTn2WT8=; + b=s1J7lJMzYi8blB4UNFnF3ZH0jacSXnbPmA+HYE7Z4bkT7ZzjtCo33xd1K5XWqruAT5 + KTDlSIN2DMKn+xhyHyTlHIY/y/vneXhlr/JaTf02Fe7yluALlfvhx+1AAaRP5XV5s21p + ADkM71OQbAKZkK5cuvAqXGouz3odmlu2zOg31VwPbJGxy+aKaWnVnLRNY9U5winu3Rmv + y5TrhV34CR6M9lFo+LmHqBX/MvD/tGdyauKbeMCDe2XuohrehDymBrNVxVprOB9dtZId + LeFoXEW+Xp2FsLA7xfbshCXrcYIMTJ1LQjuF24oiWbERHJ1IgDJng94fjOlyjmxOgC8P + qgCg== +Received: by 10.216.30.195 with SMTP id k45mr5892337wea.40.1339918068773; + Sun, 17 Jun 2012 00:27:48 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + gb9sm16419953wib.8.2012.06.17.00.27.47 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 17 Jun 2012 00:27:48 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org, + novalazy@gmail.com +Subject: [WIP 2/2] cli: add --exclude=all option to notmuch-search.c +Date: Sun, 17 Jun 2012 08:27:26 +0100 +Message-Id: <1339918046-3448-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1339918046-3448-1-git-send-email-markwalters1009@gmail.com> +References: <87zk82l7wp.fsf@qmul.ac.uk> + <1339918046-3448-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 17 Jun 2012 07:27:53 -0000 + +Add a --exclude=all option to notmuch search. + +--- + notmuch-search.c | 8 ++++++-- + test/excludes | 5 +++++ + 2 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/notmuch-search.c b/notmuch-search.c +index 3be296d..89b5bf9 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -420,6 +420,7 @@ enum { + EXCLUDE_TRUE, + EXCLUDE_FALSE, + EXCLUDE_FLAG, ++ EXCLUDE_ALL + }; + + int +@@ -461,6 +462,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, + { "false", EXCLUDE_FALSE }, + { "flag", EXCLUDE_FLAG }, ++ { "all", EXCLUDE_ALL }, + { 0, 0 } } }, + { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, + { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, +@@ -516,7 +518,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + exclude = EXCLUDE_FALSE; + } + +- if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) { ++ if (exclude != EXCLUDE_FALSE) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + +@@ -525,7 +527,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + for (i = 0; i < search_exclude_tags_length; i++) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + if (exclude == EXCLUDE_FLAG) +- notmuch_query_set_omit_excluded (query, FALSE); ++ notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); ++ if (exclude == EXCLUDE_ALL) ++ notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); + } + + switch (output) { +diff --git a/test/excludes b/test/excludes +index 24d653e..7be8d79 100755 +--- a/test/excludes ++++ b/test/excludes +@@ -166,6 +166,11 @@ ${matching_message_ids[3]} + ${matching_message_ids[4]} + ${matching_message_ids[5]}" + ++test_begin_subtest "Search, exclude=all (thread summary)" ++output=$(notmuch search --exclude=all tag:test | notmuch_search_sanitize) ++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) ++thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" ++ + test_begin_subtest "Search, default exclusion: tag in query (thread summary)" + output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize) + 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) +-- +1.7.9.1 + -- 2.26.2