From f023b6793d7fcc6060ede291a8ecefc1577d31d1 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 15 Feb 2012 09:03:29 +0000 Subject: [PATCH] [RFC PATCH v5 01/11] cli: add --no-exclude option to count and search. --- 39/6b0066d7cccce2d92e8ae8bcdfe9a3c8f17ce3 | 155 ++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 39/6b0066d7cccce2d92e8ae8bcdfe9a3c8f17ce3 diff --git a/39/6b0066d7cccce2d92e8ae8bcdfe9a3c8f17ce3 b/39/6b0066d7cccce2d92e8ae8bcdfe9a3c8f17ce3 new file mode 100644 index 000000000..399a6733f --- /dev/null +++ b/39/6b0066d7cccce2d92e8ae8bcdfe9a3c8f17ce3 @@ -0,0 +1,155 @@ +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 AAD86431FBD + for ; Wed, 15 Feb 2012 01:02:55 -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 xJOuRC0AqIPU for ; + Wed, 15 Feb 2012 01:02:55 -0800 (PST) +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 F3B9A431E82 + for ; Wed, 15 Feb 2012 01:02:54 -0800 (PST) +Received: by werp13 with SMTP id p13so603332wer.26 + for ; Wed, 15 Feb 2012 01:02:53 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=emWAclt80HEiOKvc49r6U+LEsYM7rTnjWaIKwiSuCgM=; + b=FMehFQOX+KbyCqwIRNmXuRi3FKDf7Zi0JxvD7W2EH5PaoFG7x4Li1feERAtMiwCVcw + 4nsNN/5SPIb40nOuVXunXGYxPn0lU1qnK61pdC3088dTW51CIK5IRkt6pKrY1tVONZ9h + G3kz1INfl8d06lH38GAU5Xq9GpQ2AypM3jKyM= +Received: by 10.216.137.66 with SMTP id x44mr2302901wei.41.1329296573851; + Wed, 15 Feb 2012 01:02:53 -0800 (PST) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + eq5sm7635506wib.2.2012.02.15.01.02.52 (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 15 Feb 2012 01:02:53 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [RFC PATCH v5 01/11] cli: add --no-exclude option to count and + search. +Date: Wed, 15 Feb 2012 09:03:29 +0000 +Message-Id: <1329296619-7463-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <1329296619-7463-1-git-send-email-markwalters1009@gmail.com> +References: <1329296619-7463-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: Wed, 15 Feb 2012 09:02:55 -0000 + +This option turns off the exclusion so all matching messages are +returned. We do not need to add this to notmuch-show as that does not +(yet) exclude. +--- + notmuch-count.c | 17 +++++++++++------ + notmuch-search.c | 17 +++++++++++------ + 2 files changed, 22 insertions(+), 12 deletions(-) + +diff --git a/notmuch-count.c b/notmuch-count.c +index 63459fb..5364507 100644 +--- a/notmuch-count.c ++++ b/notmuch-count.c +@@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + char *query_str; + int opt_index; + int output = OUTPUT_MESSAGES; +- const char **search_exclude_tags; +- size_t search_exclude_tags_length; ++ notmuch_bool_t no_exclude = FALSE; + unsigned int i; + + notmuch_opt_desc_t options[] = { +@@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, + { "messages", OUTPUT_MESSAGES }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, + { 0, 0, 0, 0, 0 } + }; + +@@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + return 1; + } + +- search_exclude_tags = notmuch_config_get_search_exclude_tags +- (config, &search_exclude_tags_length); +- for (i = 0; i < search_exclude_tags_length; i++) +- notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ if (!no_exclude) { ++ const char **search_exclude_tags; ++ size_t search_exclude_tags_length; ++ ++ search_exclude_tags = notmuch_config_get_search_exclude_tags ++ (config, &search_exclude_tags_length); ++ for (i = 0; i < search_exclude_tags_length; i++) ++ notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ } + + switch (output) { + case OUTPUT_MESSAGES: +diff --git a/notmuch-search.c b/notmuch-search.c +index d504051..43ec90b 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -423,8 +423,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + output_t output = OUTPUT_SUMMARY; + int offset = 0; + int limit = -1; /* unlimited */ +- const char **search_exclude_tags; +- size_t search_exclude_tags_length; ++ notmuch_bool_t no_exclude = FALSE; + unsigned int i; + + enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } +@@ -446,6 +445,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + { "files", OUTPUT_FILES }, + { "tags", OUTPUT_TAGS }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, + { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, + { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, + { 0, 0, 0, 0, 0 } +@@ -493,10 +493,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + + notmuch_query_set_sort (query, sort); + +- search_exclude_tags = notmuch_config_get_search_exclude_tags +- (config, &search_exclude_tags_length); +- for (i = 0; i < search_exclude_tags_length; i++) +- notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ if (!no_exclude) { ++ const char **search_exclude_tags; ++ size_t search_exclude_tags_length; ++ ++ search_exclude_tags = notmuch_config_get_search_exclude_tags ++ (config, &search_exclude_tags_length); ++ for (i = 0; i < search_exclude_tags_length; i++) ++ notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); ++ } + + switch (output) { + default: +-- +1.7.2.3 + -- 2.26.2