Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id AEB49429E5D for ; Sat, 17 Aug 2013 05:11:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FelIe38QyDgs for ; Sat, 17 Aug 2013 05:11:36 -0700 (PDT) Received: from mail-bk0-f45.google.com (mail-bk0-f45.google.com [209.85.214.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id F0E1C431E82 for ; Sat, 17 Aug 2013 05:11:35 -0700 (PDT) Received: by mail-bk0-f45.google.com with SMTP id mx11so913478bkb.18 for ; Sat, 17 Aug 2013 05:11:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=MmYw4TKA8Xbd3O7DA8EMUslE6/k1CJwzGMT8Xl+cCVk=; b=jgkTvEAc90fq8yGQ40OGN2nY0Y4H0aeTWplMqE+/MAiOcPG3J0WF1E6NkFgN5yJcl5 blnNm04IcnejzWJTqf1ESbokq0XiOU1eEqfzo5YK02K9ThurwaS+ozIlSEOOpm4sAjOm 2i7DXUYtWpuMEk3JIUB1NC4MpcwF0y3Uydvg41o3Tt7pAlRlRR/v75t22GCiKAQCmp/n nziAncJEDh36iLQMXfiog+1LR3xYhhLakojy5EZRBn0xv3CWDmVXUBPzhhveQbpl8btz KaYNXSN1Z+uS7b5LQg18OsJfLNfwfgQ//iQR0GIW2qrpgAGraivGbQscvvcvd4f2DZfF 7Z1g== X-Gm-Message-State: ALoCoQnpaZcOBN9tzENBgQ5nebTUG2SE6cuxwmG1MucHRNopeXvamBfdBSksh/3+TY/YT5nQaowu X-Received: by 10.205.10.132 with SMTP id pa4mr3931980bkb.15.1376741493407; Sat, 17 Aug 2013 05:11:33 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id h5sm249685bkg.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 17 Aug 2013 05:11:32 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v3 1/8] cli: add --duplicate=N option to notmuch search Date: Sat, 17 Aug 2013 15:11:26 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Aug 2013 12:11:41 -0000 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 a96f07d..d9d39ec 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 ); @@ -296,6 +300,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) int offset = 0; int limit = -1; /* unlimited */ notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE; + int dupe = -1; unsigned int i; enum { @@ -332,6 +337,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 } }; @@ -414,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); -- 1.7.10.4