[PATCH v4 3/6] cli: move search to the new --exclude= naming scheme.
authorMark Walters <markwalters1009@gmail.com>
Sat, 7 Apr 2012 16:10:05 +0000 (17:10 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:06 +0000 (09:46 -0800)
0d/748648a849332a72fa4dac71b86653a2145838 [new file with mode: 0644]

diff --git a/0d/748648a849332a72fa4dac71b86653a2145838 b/0d/748648a849332a72fa4dac71b86653a2145838
new file mode 100644 (file)
index 0000000..a05b60d
--- /dev/null
@@ -0,0 +1,200 @@
+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 9AA66431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  7 Apr 2012 09:10:38 -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 YJ3GEfC20Hcu for <notmuch@notmuchmail.org>;\r
+       Sat,  7 Apr 2012 09:10:37 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 66470431FD6   for <notmuch@notmuchmail.org>; Sat,  7 Apr 2012 09:10:33 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f45.google.com with SMTP id dt14so822285wgb.2\r
+       for <notmuch@notmuchmail.org>; Sat, 07 Apr 2012 09:10:33 -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=RNjegDaofYgFUQpzYcXKNg4I08qTfgYpkZy4yVH/O1g=;\r
+       b=u6Puc1VuJxHWdhNFV2V5LN2yjcrm7t/MsBXRNt/LZpkMxFdgBSWj0IpTxempYCOGK7\r
+       fIMQOZZACL+tjlFPLDN5JuXC0l3gageV2Y15eM36f2BOMXdjPOjZv3dcNjfab++b/I3Z\r
+       dCqTy1z3hr5FgyB5ABAwrvMX75G7fX/GiwTI2wQBSPLDC5J/+oUdFB6UDvLZgBWdyAGj\r
+       RH1s5Sf2G6Oxh0IDA7KqWqrlNxt8W3DiMiPSdkSHd1f0oQKFNeuU8oEG62tIvwNXsrsu\r
+       t1vL9ymov7s1nXF576+aLRvP/canHkvjQKfx5x6QRi7m1lyNLlbjrGJGENykjbeVCAga\r
+       z7MQ==\r
+Received: by 10.216.150.148 with SMTP id z20mr1046402wej.22.1333815033050;\r
+       Sat, 07 Apr 2012 09:10:33 -0700 (PDT)\r
+Received: from localhost (94.197.17.51.threembb.co.uk. [94.197.17.51])\r
+       by mx.google.com with ESMTPS id o2sm25308770wiv.11.2012.04.07.09.10.26\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 07 Apr 2012 09:10:32 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 3/6] cli: move search to the new --exclude= naming scheme.\r
+Date: Sat,  7 Apr 2012 17:10:05 +0100\r
+Message-Id: <1333815008-24668-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1333815008-24668-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1333815008-24668-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: Sat, 07 Apr 2012 16:10:39 -0000\r
+\r
+This commit replaces the --no-exclude option with a\r
+--exclude=(true|false|flag) option. The default is to omit the\r
+excluded messages.\r
+\r
+The flag option only makes sense if output=summary (as otherwise there\r
+is nowhere to print the flag). In summary output exclude=false and\r
+exclude=flag give almost identical output:\r
+they differ in that with the exclude=flag option the match count\r
+(i.e., the x in [x/n] in the output) is the number of matching\r
+non-excluded messages rather than the number of matching messages.\r
+\r
+Note this changes the default for output=summary when no --exclude=\r
+option is given: it used to default to flag and now defaults to true\r
+(i.e. omit excluded messages). This is neccesary to keep the cli\r
+output uncluttered and for speed reasons.\r
+---\r
+ man/man1/notmuch-search.1 |   12 +++++++++---\r
+ notmuch-search.c          |   32 +++++++++++++++++++++++---------\r
+ 2 files changed, 32 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1\r
+index 06d81a6..ebb61fc 100644\r
+--- a/man/man1/notmuch-search.1\r
++++ b/man/man1/notmuch-search.1\r
+@@ -114,9 +114,15 @@ Limit the number of displayed results to N.\r
+ \r
+ .RS 4\r
+ .TP 4\r
+-.BR \-\-no\-exclude\r
+-\r
+-Do not exclude the messages matching search.exclude_tags in the config file.\r
++.BR \-\-exclude=(true|false|flag)\r
++\r
++Specify whether to omit messages matching search.tag_exclude from the\r
++search results (the default) or not. The extra option\r
++.B flag\r
++only has an effect when\r
++.B --output=summary\r
++In this case all matching threads are returned but the "match count"\r
++is the number of matching non-excluded messages in the thread.\r
+ .RE\r
+ \r
+ .SH SEE ALSO\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index f6061e4..1cc8430 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -210,9 +210,6 @@ 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
+@@ -303,8 +300,6 @@ 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
+@@ -376,7 +371,6 @@ 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
+@@ -422,6 +416,12 @@ do_search_tags (notmuch_database_t *notmuch,\r
+     return 0;\r
+ }\r
+ \r
++enum {\r
++    EXCLUDE_TRUE,\r
++    EXCLUDE_FALSE,\r
++    EXCLUDE_FLAG,\r
++};\r
++\r
+ int\r
+ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ {\r
+@@ -435,7 +435,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+     output_t output = OUTPUT_SUMMARY;\r
+     int offset = 0;\r
+     int limit = -1; /* unlimited */\r
+-    notmuch_bool_t no_exclude = FALSE;\r
++    int exclude = EXCLUDE_TRUE;\r
+     unsigned int i;\r
+ \r
+     enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
+@@ -457,7 +457,11 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+                                 { "files", OUTPUT_FILES },\r
+                                 { "tags", OUTPUT_TAGS },\r
+                                 { 0, 0 } } },\r
+-      { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
++        { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
++          (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
++                                  { "false", EXCLUDE_FALSE },\r
++                                  { "flag", EXCLUDE_FLAG },\r
++                                  { 0, 0 } } },\r
+       { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+       { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
+       { 0, 0, 0, 0, 0 }\r
+@@ -505,7 +509,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+ \r
+     notmuch_query_set_sort (query, sort);\r
+ \r
+-    if (!no_exclude) {\r
++    if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) {\r
++      /* If we are not doing summary output there is nowhere to\r
++       * print the excluded flag so fall back on including the\r
++       * excluded messages. */\r
++      fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n");\r
++      exclude = EXCLUDE_FALSE;\r
++    }\r
++\r
++    if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) {\r
+       const char **search_exclude_tags;\r
+       size_t search_exclude_tags_length;\r
+ \r
+@@ -513,6 +525,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
+           (config, &search_exclude_tags_length);\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
+     }\r
+ \r
+     switch (output) {\r
+-- \r
+1.7.9.1\r
+\r