[PATCH v2] cli: clarify correspondence of --exclude to omit_excluded in search
Peter Wang
novalazy at gmail.com
Mon May 13 07:20:15 PDT 2013
Make it obvious how the --exclude command-line option affects the
omit_excluded field in notmuch_query_t objects, with an explicit and
exhaustive switch. Do not expect the reader to know the default value
of omit_excluded.
---
This can be inserted after patch 2.
notmuch-search.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/notmuch-search.c b/notmuch-search.c
index 4323201..893df10 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -290,6 +290,24 @@ enum {
EXCLUDE_ALL
};
+static int
+exclude_option_to_omit_excluded (int exclude)
+{
+ switch (exclude) {
+ case EXCLUDE_TRUE:
+ return NOTMUCH_EXCLUDE_TRUE;
+ case EXCLUDE_FALSE:
+ return NOTMUCH_EXCLUDE_FALSE;
+ case EXCLUDE_FLAG:
+ return NOTMUCH_EXCLUDE_FALSE;
+ case EXCLUDE_ALL:
+ return NOTMUCH_EXCLUDE_ALL;
+ default:
+ INTERNAL_ERROR ("unhandled exclude option %d", exclude);
+ /*UNREACHED*/
+ }
+}
+
int
notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
{
@@ -410,11 +428,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
(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 (exclude == EXCLUDE_FLAG)
- notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE);
- if (exclude == EXCLUDE_ALL)
- notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);
}
+ notmuch_query_set_omit_excluded (query, exclude_option_to_omit_excluded (exclude));
switch (output) {
default:
--
1.7.12.1
More information about the notmuch
mailing list