1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 935FF429E32
\r
6 for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:50 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id KA0jZ0XY482X for <notmuch@notmuchmail.org>;
\r
17 Fri, 28 Oct 2011 13:59:49 -0700 (PDT)
\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com
\r
19 [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 5A918429E21
\r
22 for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:47 -0700 (PDT)
\r
23 Received: by mail-fx0-f53.google.com with SMTP id i28so4419077faa.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:47 -0700 (PDT)
\r
25 Received: by 10.223.92.135 with SMTP id r7mr8801871fam.35.1319835587101;
\r
26 Fri, 28 Oct 2011 13:59:47 -0700 (PDT)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id j5sm19444105faf.14.2011.10.28.13.59.45
\r
30 (version=SSLv3 cipher=OTHER); Fri, 28 Oct 2011 13:59:46 -0700 (PDT)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [RFC PATCH 2/3] cli: add support for limiting the number of search
\r
35 Date: Fri, 28 Oct 2011 23:59:30 +0300
\r
37 <f16c7983a8a639ea2ed1178a3190afb9620153e2.1319833617.git.jani@nikula.org>
\r
38 X-Mailer: git-send-email 1.7.5.4
\r
39 In-Reply-To: <cover.1319833617.git.jani@nikula.org>
\r
40 References: <cover.1319833617.git.jani@nikula.org>
\r
41 In-Reply-To: <cover.1319833617.git.jani@nikula.org>
\r
42 References: <cover.1319833617.git.jani@nikula.org>
\r
43 Cc: amdragon@mit.edu
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Fri, 28 Oct 2011 20:59:51 -0000
\r
58 Add command line parameter --maxitems=N to notmuch search to limit the
\r
59 number of displayed messages to N.
\r
61 These two are equal:
\r
63 $ notmuch search --output=messages --sort=newest-first --maxitems=10 SEARCH
\r
64 $ notmuch search --output=messages --sort=newest-first SEARCH | head
\r
68 $ notmuch search --output=messages --sort=oldest-first --maxitems=10 SEARCH
\r
69 $ notmuch search --output=messages --sort=oldest-first SEARCH | tail
\r
71 Note that N refers to the maximum amount of messages, even for
\r
74 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
76 notmuch-search.c | 10 ++++++++++
\r
77 1 files changed, 10 insertions(+), 0 deletions(-)
\r
79 diff --git a/notmuch-search.c b/notmuch-search.c
\r
80 index 6f04d9a..a3a6475 100644
\r
81 --- a/notmuch-search.c
\r
82 +++ b/notmuch-search.c
\r
83 @@ -394,6 +394,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
84 const search_format_t *format = &format_text;
\r
86 output_t output = OUTPUT_SUMMARY;
\r
87 + unsigned int maxitems = 0;
\r
89 argc--; argv++; /* skip subcommand argument */
\r
91 @@ -412,6 +413,14 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
92 fprintf (stderr, "Invalid value for --sort: %s\n", opt);
\r
95 + } else if (STRNCMP_LITERAL (argv[i], "--maxitems=") == 0) {
\r
97 + opt = argv[i] + sizeof ("--maxitems=") - 1;
\r
98 + maxitems = strtoul(opt, &p, 10);
\r
99 + if (*opt == '\0' || p == opt || *p != '\0') {
\r
100 + fprintf (stderr, "Invalid value for --maxitems: %s\n", opt);
\r
103 } else if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
\r
104 opt = argv[i] + sizeof ("--format=") - 1;
\r
105 if (strcmp (opt, "text") == 0) {
\r
106 @@ -473,6 +482,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
109 notmuch_query_set_sort (query, sort);
\r
110 + notmuch_query_set_maxitems (query, maxitems);
\r