[PATCH v2 8/8] cli: use notmuch_exclude_t in option parser
authorMark Walters <markwalters1009@gmail.com>
Sat, 11 May 2013 19:50:09 +0000 (20:50 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:54:41 +0000 (09:54 -0800)
71/71dc091d0c1ec71e67ccc1b520edcbecdc8668 [new file with mode: 0644]

diff --git a/71/71dc091d0c1ec71e67ccc1b520edcbecdc8668 b/71/71dc091d0c1ec71e67ccc1b520edcbecdc8668
new file mode 100644 (file)
index 0000000..2278099
--- /dev/null
@@ -0,0 +1,147 @@
+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 84911431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:51:05 -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 j0boS9StpVLU for <notmuch@notmuchmail.org>;\r
+       Sat, 11 May 2013 12:51:01 -0700 (PDT)\r
+Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
+       [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 7E687431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:50:33 -0700 (PDT)\r
+Received: by mail-wi0-f174.google.com with SMTP id m6so1665855wiv.13\r
+       for <notmuch@notmuchmail.org>; Sat, 11 May 2013 12:50:32 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+       :references; bh=WhkSakuUpmVWKTAeP5Lf7/ylkSaMYytH53P0lW8xkg4=;\r
+       b=0xiJbZMk99ZgZCzbiq6DsuhFSpnjKdSUc2AqkOW3N4UehniU6M1bYeJd5Oe0YHnzVo\r
+       yFLLGjomNZv638ZuGDZiXn5cN6CRn7Oott3ZBU7Lc/uhJdj9F4rtXEFR9PUBzrYdx8a/\r
+       o8FdO3LOurFZ5cPmiK9/+MSbLJpuOAVvoUoxNKyHPa55m7nXcBXCTMt4Ub6PaS5tdkv6\r
+       RVod5KPAPl//ZuDuAUhlL07nSCTbNpUAwlWp8gDuJYzooRx8oHit+a5/87SYRNOfefaA\r
+       2LR2U1p+G9RTNKues1QUbp/PQFZQQ97/lqROfUlsMf2RNXQngeFw2Dt5g2tsi0CDRC5C\r
+       5RWg==\r
+X-Received: by 10.194.133.232 with SMTP id pf8mr9741120wjb.40.1368301832459;\r
+       Sat, 11 May 2013 12:50:32 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPSA id bs20sm5729767wib.0.2013.05.11.12.50.31\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 11 May 2013 12:50:32 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 8/8] cli: use notmuch_exclude_t in option parser\r
+Date: Sat, 11 May 2013 20:50:09 +0100\r
+Message-Id: <1368301809-12532-9-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1368301809-12532-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, 11 May 2013 19:51:05 -0000\r
+\r
+From: Peter Wang <novalazy@gmail.com>\r
+\r
+Use notmuch_exclude_t constants directly instead of a redundant\r
+enumeration while parsing search --exclude keyword arguments.\r
+---\r
+ notmuch-search.c |   28 +++++++++-------------------\r
+ 1 files changed, 9 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index a20791a..a96f07d 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -283,13 +283,6 @@ do_search_tags (notmuch_database_t *notmuch,\r
+     return 0;\r
+ }\r
\r
+-enum {\r
+-    EXCLUDE_TRUE,\r
+-    EXCLUDE_FALSE,\r
+-    EXCLUDE_FLAG,\r
+-    EXCLUDE_ALL\r
+-};\r
+-\r
+ int\r
+ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+@@ -302,7 +295,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+     output_t output = OUTPUT_SUMMARY;\r
+     int offset = 0;\r
+     int limit = -1; /* unlimited */\r
+-    int exclude = EXCLUDE_TRUE;\r
++    notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE;\r
+     unsigned int i;\r
\r
+     enum {\r
+@@ -332,10 +325,10 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+                                 { "tags", OUTPUT_TAGS },\r
+                                 { 0, 0 } } },\r
+         { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
+-          (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
+-                                  { "false", EXCLUDE_FALSE },\r
+-                                  { "flag", EXCLUDE_FLAG },\r
+-                                  { "all", EXCLUDE_ALL },\r
++          (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
++                                  { "false", NOTMUCH_EXCLUDE_FALSE },\r
++                                  { "flag", NOTMUCH_EXCLUDE_FLAG },\r
++                                  { "all", NOTMUCH_EXCLUDE_ALL },\r
+                                   { 0, 0 } } },\r
+       { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+       { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
+@@ -394,15 +387,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
\r
+     notmuch_query_set_sort (query, sort);\r
\r
+-    if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) {\r
++    if (exclude == NOTMUCH_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
++      exclude = NOTMUCH_EXCLUDE_FALSE;\r
+     }\r
\r
+-    if (exclude != EXCLUDE_FALSE) {\r
++    if (exclude != NOTMUCH_EXCLUDE_FALSE) {\r
+       const char **search_exclude_tags;\r
+       size_t search_exclude_tags_length;\r
\r
+@@ -410,10 +403,7 @@ notmuch_search_command (notmuch_config_t *config, 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, NOTMUCH_EXCLUDE_FLAG);\r
+-      if (exclude == EXCLUDE_ALL)\r
+-          notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);\r
++      notmuch_query_set_omit_excluded (query, exclude);\r
+     }\r
\r
+     switch (output) {\r
+-- \r
+1.7.9.1\r
+\r