From: Jani Nikula Date: Mon, 13 May 2013 18:26:56 +0000 (+0300) Subject: [PATCH 1/6] cli: add --duplicate=N option to notmuch search X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ebf3ee78a40571f96cc6c57cbaccbbf7bbcdcf5f;p=notmuch-archives.git [PATCH 1/6] cli: add --duplicate=N option to notmuch search --- diff --git a/98/a07ef3151e564d1ba51bf95cd8cc626df5a88f b/98/a07ef3151e564d1ba51bf95cd8cc626df5a88f new file mode 100644 index 000000000..28c78c407 --- /dev/null +++ b/98/a07ef3151e564d1ba51bf95cd8cc626df5a88f @@ -0,0 +1,142 @@ +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 24C56431FCB + for ; Mon, 13 May 2013 11:27:15 -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 66yGVp3Q2ZQ3 for ; + Mon, 13 May 2013 11:27:08 -0700 (PDT) +Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com + [209.85.217.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 55B6B431FB6 + for ; Mon, 13 May 2013 11:27:08 -0700 (PDT) +Received: by mail-lb0-f172.google.com with SMTP id y6so6753519lbh.17 + for ; Mon, 13 May 2013 11:27:07 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to + :references:in-reply-to:references:x-gm-message-state; + bh=L9oiFgYVSiNm4FJrD523wA+nQgGpV1nAEupggcD1yTE=; + b=RTkyUBNfZt8PeU+cZ27YuHEcTZ2rcNC6ZFydkcniu0Hzr70OmCcTI3qwM+FQ2ERa7f + s0zygtNUC1nXWc7Smdj/ts7OyD3zFj/hoPEMyqRsHvO1Z1trld1XaTiTQmPiCg1z4SIA + SNXi+XmebADb6LoUsXNG4/8iCIEyJtgIxBv5RyOBMsXH64G4e0YqPkCiRg2GncQ65AV/ + Y+Cs3YinC3OPfZSTT4XPTLFaCWeBGVup2Thv+7SMAsxh0gGDKDfzuxO1UJ/kCZWHCkZu + 4V0ZHh9AYYwW8WqidmYGHlHP3XyCIwHT73ezghcuy1sXcZpLorGH1oXXBWsQN74+BOLr + zE2A== +X-Received: by 10.112.151.3 with SMTP id um3mr13527711lbb.102.1368469626920; + Mon, 13 May 2013 11:27:06 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi. + [88.195.118.211]) + by mx.google.com with ESMTPSA id y3sm5913558lby.12.2013.05.13.11.27.05 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Mon, 13 May 2013 11:27:06 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 1/6] cli: add --duplicate=N option to notmuch search +Date: Mon, 13 May 2013 21:26:56 +0300 +Message-Id: + <8f40230af59a6d13eaf986cb0793202a8686c097.1368467532.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: +References: +In-Reply-To: +References: +X-Gm-Message-State: + ALoCoQlguMF6jpHLB1lbmx9MytrI8q5B2dERITw37bM8/oXFmEm4POaKLj9fq6il7yold4apLrzU +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: Mon, 13 May 2013 18:27:15 -0000 + +Effective with --output=files, output the Nth filename associated with +each message matching the query (N is 0-based). If N is equal to or +greater than the number of files associated with the message, don't +print anything. +--- + notmuch-search.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/notmuch-search.c b/notmuch-search.c +index e658639..b113883 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 = 0; + 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 ); +@@ -302,6 +306,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 { +@@ -337,6 +342,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 } + }; + +@@ -420,7 +426,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 +