[PATCH v2] cli: clarify correspondence of --exclude to omit_excluded in search
authorPeter Wang <novalazy@gmail.com>
Mon, 13 May 2013 14:20:15 +0000 (00:20 +1000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:54:43 +0000 (09:54 -0800)
4f/a3715887726402bde2a622b4de4bab61685054 [new file with mode: 0644]

diff --git a/4f/a3715887726402bde2a622b4de4bab61685054 b/4f/a3715887726402bde2a622b4de4bab61685054
new file mode 100644 (file)
index 0000000..eb3ca11
--- /dev/null
@@ -0,0 +1,119 @@
+Return-Path: <novalazy@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 B2022431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 13 May 2013 07:20:36 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, 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 87EKU+b+X4vn for <notmuch@notmuchmail.org>;\r
+       Mon, 13 May 2013 07:20:31 -0700 (PDT)\r
+Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com\r
+       [209.85.220.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 28A27431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 13 May 2013 07:20:31 -0700 (PDT)\r
+Received: by mail-pa0-f50.google.com with SMTP id fb10so4616819pad.23\r
+       for <notmuch@notmuchmail.org>; Mon, 13 May 2013 07:20:30 -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=egNzpeoyPhsaR+IxbSLHUjrlVwa66ky0s5ooVduz6gI=;\r
+       b=xiGF/bkiBNEOorkMPHD6zYreBz4fjyCge9KIFxT5mu0JssSZNuX5bdybIwY3RHUaeN\r
+       rj8+5YsWiZ/wp/kOaRP+HldUJOsBVaOT01nt0PqYwJieM5xDPqg+5Aud8OykNVlM1yNc\r
+       OJXs/aD2JHE0lLdUfhcQ0bUAIDRE9jmkI11pgInv4WUt4F0hakA+MHo6og2QNIq1eB4Y\r
+       mVaHnbkkg3fEiyExbmH9mPZ4lID4gz1DP9TfI0jvBHsGhZgs36fDLuATAPnWYN5y8MjX\r
+       7hOz4/bDgEG+L960clc1xIoOPPRagaQl9cVfl3gcN6KBg/4lS4r37juK6FgGYHljNJNl\r
+       0YgA==\r
+X-Received: by 10.66.218.170 with SMTP id ph10mr30529077pac.134.1368454830472;\r
+       Mon, 13 May 2013 07:20:30 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPSA id 10sm14219628pbr.45.2013.05.13.07.20.27\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Mon, 13 May 2013 07:20:29 -0700 (PDT)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] cli: clarify correspondence of --exclude to omit_excluded\r
+       in search\r
+Date: Tue, 14 May 2013 00:20:15 +1000\r
+Message-Id: <1368454815-1854-1-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.12.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: Mon, 13 May 2013 14:20:36 -0000\r
+\r
+Make it obvious how the --exclude command-line option affects the\r
+omit_excluded field in notmuch_query_t objects, with an explicit and\r
+exhaustive switch.  Do not expect the reader to know the default value\r
+of omit_excluded.\r
+---\r
+This can be inserted after patch 2.\r
+\r
+ notmuch-search.c | 23 +++++++++++++++++++----\r
+ 1 file changed, 19 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 4323201..893df10 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -290,6 +290,24 @@ enum {\r
+     EXCLUDE_ALL\r
+ };\r
\r
++static int\r
++exclude_option_to_omit_excluded (int exclude)\r
++{\r
++    switch (exclude) {\r
++    case EXCLUDE_TRUE:\r
++      return NOTMUCH_EXCLUDE_TRUE;\r
++    case EXCLUDE_FALSE:\r
++      return NOTMUCH_EXCLUDE_FALSE;\r
++    case EXCLUDE_FLAG:\r
++      return NOTMUCH_EXCLUDE_FALSE;\r
++    case EXCLUDE_ALL:\r
++      return NOTMUCH_EXCLUDE_ALL;\r
++    default:\r
++      INTERNAL_ERROR ("unhandled exclude option %d", exclude);\r
++      /*UNREACHED*/\r
++    }\r
++}\r
++\r
+ int\r
+ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+@@ -410,11 +428,8 @@ 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_FALSE);\r
+-      if (exclude == EXCLUDE_ALL)\r
+-          notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);\r
+     }\r
++    notmuch_query_set_omit_excluded (query, exclude_option_to_omit_excluded (exclude));\r
\r
+     switch (output) {\r
+     default:\r
+-- \r
+1.7.12.1\r
+\r