---
 notmuch-search.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index f6061e4..2fa4231 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -436,6 +436,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
     int offset = 0;
     int limit = -1; /* unlimited */
     notmuch_bool_t no_exclude = FALSE;
+    notmuch_bool_t secondary_search = FALSE;
+    char *secondary_search_terms = NULL;
+    notmuch_ss_conjunction_t ss_conjunction = NOTMUCH_SECONDARY_SEARCH_NONE;
     unsigned int i;
 
     enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
@@ -458,6 +461,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
                                  { "tags", OUTPUT_TAGS },
                                  { 0, 0 } } },
        { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
+       { NOTMUCH_OPT_BOOLEAN, &secondary_search, "secondary-search", 'd', 0 },
        { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
        { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },
        { 0, 0, 0, 0, 0 }
@@ -478,6 +482,18 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
        break;
     }
 
+    if (secondary_search && argc-opt_index >= 2 ) {
+       if (strcmp (argv[argc - 2], ":AND:") == 0)
+           ss_conjunction = NOTMUCH_SECONDARY_SEARCH_AND;
+       if (strcmp (argv[argc - 2], ":AND_NOT:") == 0)
+           ss_conjunction = NOTMUCH_SECONDARY_SEARCH_AND_NOT;
+
+       if (ss_conjunction != NOTMUCH_SECONDARY_SEARCH_NONE) {
+           secondary_search_terms = argv[argc - 1];
+           argc -= 2;
+       }
+    }
+
     config = notmuch_config_open (ctx, NULL, NULL);
     if (config == NULL)
        return 1;
@@ -505,6 +521,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 
     notmuch_query_set_sort (query, sort);
 
+    if (secondary_search_terms)
+       notmuch_query_set_secondary_search (query, secondary_search_terms, 
ss_conjunction);
+
     if (!no_exclude) {
        const char **search_exclude_tags;
        size_t search_exclude_tags_length;
-- 
1.7.9.1

_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to