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