From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v3] cli: add --duplicate=N option to notmuch search
Date: Mon, 10 Jun 2013 18:57:03 +0300 [thread overview]
Message-ID: <1370879823-1388-1-git-send-email-jani@nikula.org> (raw)
In-Reply-To: <61ed86f221d65b4dba438cbc2b4c5b77a484a534.1370775663.git.jani@nikula.org>
Effective with --output=files, output the Nth filename associated with
each message matching the query (N is 1-based). If N is greater than
the number of files associated with the message, don't print anything.
---
v3: fix commit message, no other changes
---
notmuch-search.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/notmuch-search.c b/notmuch-search.c
index 4323201..196934b 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 );
@@ -303,6 +307,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
int offset = 0;
int limit = -1; /* unlimited */
int exclude = EXCLUDE_TRUE;
+ int dupe = -1;
unsigned int i;
enum {
@@ -339,6 +344,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
{ 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 }
};
@@ -424,7 +430,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);
--
1.7.10.4
next prev parent reply other threads:[~2013-06-10 15:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 11:03 [PATCH v2 0/7] cli: better tooling support for duplicate messages Jani Nikula
2013-06-09 11:03 ` [PATCH v2 1/7] cli: add --duplicate=N option to notmuch search Jani Nikula
2013-06-09 20:22 ` Mark Walters
2013-06-10 16:49 ` Jani Nikula
2013-06-10 15:57 ` Jani Nikula [this message]
2013-06-09 11:03 ` [PATCH v2 2/7] test: test notmuch search --duplicate=N Jani Nikula
2013-06-09 11:03 ` [PATCH v2 3/7] man: document " Jani Nikula
2013-06-09 13:20 ` Mark Walters
2013-06-09 13:25 ` Mark Walters
2013-06-10 16:39 ` Jani Nikula
2013-06-10 16:28 ` [PATCH v3] " Jani Nikula
2013-06-09 11:03 ` [PATCH v2 4/7] cli: add --output=files option to notmuch count Jani Nikula
2013-06-09 11:03 ` [PATCH v2 5/7] test: test notmuch count --output=files Jani Nikula
2013-06-09 11:03 ` [PATCH v2 6/7] man: document " Jani Nikula
2013-06-09 11:03 ` [PATCH v2 7/7] NEWS: cli options for improved duplicate message handling Jani Nikula
2013-06-10 15:30 ` [PATCH v2 0/7] cli: better tooling support for duplicate messages Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370879823-1388-1-git-send-email-jani@nikula.org \
--to=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).