X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-search.c;h=d9d39ec35b1607ada4855145cc23f7b0322e1af2;hp=43232011ceef788651f71b04056a8d3ada6b87be;hb=0b46d0fd2e37083bc0d19056aa95e1ad261cd2d6;hpb=f0dfda5c7797f9db81ce35d270fe0ac406c7fca1 diff --git a/notmuch-search.c b/notmuch-search.c index 43232011..d9d39ec3 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -177,7 +177,8 @@ do_search_messages (sprinter_t *format, notmuch_query_t *query, output_t output, int offset, - int limit) + int limit, + int dupe) { notmuch_message_t *message; notmuch_messages_t *messages; @@ -206,14 +207,17 @@ do_search_messages (sprinter_t *format, message = notmuch_messages_get (messages); if (output == OUTPUT_FILES) { + int j; filenames = notmuch_message_get_filenames (message); - for (; + for (j = 1; notmuch_filenames_valid (filenames); - notmuch_filenames_move_to_next (filenames)) + notmuch_filenames_move_to_next (filenames), j++) { - format->string (format, notmuch_filenames_get (filenames)); - format->separator (format); + if (dupe < 0 || dupe == j) { + format->string (format, notmuch_filenames_get (filenames)); + format->separator (format); + } } notmuch_filenames_destroy( filenames ); @@ -283,13 +287,6 @@ do_search_tags (notmuch_database_t *notmuch, return 0; } -enum { - EXCLUDE_TRUE, - EXCLUDE_FALSE, - EXCLUDE_FLAG, - EXCLUDE_ALL -}; - int notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { @@ -302,7 +299,8 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) output_t output = OUTPUT_SUMMARY; int offset = 0; int limit = -1; /* unlimited */ - int exclude = EXCLUDE_TRUE; + notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE; + int dupe = -1; unsigned int i; enum { @@ -332,13 +330,14 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) { "tags", OUTPUT_TAGS }, { 0, 0 } } }, { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', - (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, - { "false", EXCLUDE_FALSE }, - { "flag", EXCLUDE_FLAG }, - { "all", EXCLUDE_ALL }, + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, + { "false", NOTMUCH_EXCLUDE_FALSE }, + { "flag", NOTMUCH_EXCLUDE_FLAG }, + { "all", NOTMUCH_EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, + { NOTMUCH_OPT_INT, &dupe, "duplicate", 'D', 0 }, { 0, 0, 0, 0, 0 } }; @@ -394,15 +393,15 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_query_set_sort (query, sort); - if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { + if (exclude == NOTMUCH_EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { /* If we are not doing summary output there is nowhere to * print the excluded flag so fall back on including the * excluded messages. */ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n"); - exclude = EXCLUDE_FALSE; + exclude = NOTMUCH_EXCLUDE_FALSE; } - if (exclude != EXCLUDE_FALSE) { + if (exclude != NOTMUCH_EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -410,10 +409,7 @@ 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); } switch (output) { @@ -424,7 +420,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) break; case OUTPUT_MESSAGES: case OUTPUT_FILES: - ret = do_search_messages (format, query, output, offset, limit); + ret = do_search_messages (format, query, output, offset, limit, dupe); break; case OUTPUT_TAGS: ret = do_search_tags (notmuch, format, query);