From 86e6c6c6931281a8c5c4e82e9c267b93bd83221d Mon Sep 17 00:00:00 2001 From: Titus von der Malsburg Date: Fri, 27 Sep 2013 16:11:04 +0200 Subject: [PATCH] Added maxnum argument to mu find. --- man/mu-find.1 | 6 +++++- mu/mu-cmd-find.c | 2 ++ mu/mu-config.c | 2 ++ mu/mu-config.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/man/mu-find.1 b/man/mu-find.1 index 152bd4f7..d67d46ad 100644 --- a/man/mu-find.1 +++ b/man/mu-find.1 @@ -1,4 +1,4 @@ -.TH MU FIND 1 "June 2013" "User Manuals" +.TH MU FIND 1 "September 2013" "User Manuals" .SH NAME @@ -343,6 +343,10 @@ Note, if you specify a sortfield, by default, messages are sorted in reverse (descending) order (e.g., from lowest to highest). This is usually a good choice, but for dates it may be more useful to sort in the opposite direction. +.TP +\fB\-n\fR, \fB\-\-maxnum=\fR +If > 0, display maximally that number of entries. If not specified, all matching entries are displayed. + .TP \fB\-\-summary-len=\fR If > 0, use that number of lines of the message to provide a summary. diff --git a/mu/mu-cmd-find.c b/mu/mu-cmd-find.c index 05ec4ad8..d262275e 100644 --- a/mu/mu-cmd-find.c +++ b/mu/mu-cmd-find.c @@ -598,6 +598,8 @@ output_query_results (MuMsgIter *iter, MuConfig *opts, GError **err) MuMsg *msg; + if (opts->maxnum > 0 && count == opts->maxnum) + break; msg = get_message (iter, opts->after); if (!msg) break; diff --git a/mu/mu-config.c b/mu/mu-config.c index bfd1e104..132b4b6c 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -205,6 +205,8 @@ config_options_group_find (void) {"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield, "field to sort on", ""}, + {"maxnum", 'n', 0, G_OPTION_ARG_INT, &MU_CONFIG.maxnum, + "number of entries to display in the output", ""}, {"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads, "show message threads", NULL}, {"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark, diff --git a/mu/mu-config.h b/mu/mu-config.h index dfd278d2..08636246 100644 --- a/mu/mu-config.h +++ b/mu/mu-config.h @@ -123,6 +123,7 @@ struct _MuConfig { /* options for querying 'find' (and view-> 'summary') */ gchar *fields; /* fields to show in output */ gchar *sortfield; /* field to sort by (string) */ + int maxnum; /* max # of entries to print */ gboolean reverse; /* sort in revers order (z->a) */ gboolean threads; /* show message threads */