--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1AA98431FD0\r
+ for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id sQKeSvw9-uro for <notmuch@notmuchmail.org>;\r
+ Mon, 10 Jun 2013 09:49:50 -0700 (PDT)\r
+Received: from mail-la0-f44.google.com (mail-la0-f44.google.com\r
+ [209.85.215.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id AD37B431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:49 -0700 (PDT)\r
+Received: by mail-la0-f44.google.com with SMTP id er20so5955107lab.3\r
+ for <notmuch@notmuchmail.org>; Mon, 10 Jun 2013 09:49:48 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type:x-gm-message-state;\r
+ bh=Al9+cOvOAtoI9T1o2JzSTk7hTeu0+naIAmYz9Igf4tg=;\r
+ b=KyO0D5DTmgFBoVk4E/x3k9xwpPycvt46GR4jTnkC4w/02CzQr+jMlVz3SPKqg5JcEL\r
+ U2gb4sZ1i46YkZmH4De7jgExznQVVtJdzzgGS3mEdc7FH/JbeLq0YWmV5GnrvRs/i9TR\r
+ TR+JaHgeSm2G47igqh1oDrie9VZOLp3DbYXZBzQ3kUbj3OtXjx/oLA4JhGBxcvyHu0lK\r
+ 4ZHhrgTJG6A78WmQRZOWFvHSAj27+X8QBNPRBRoiuVhqi6cIJWbIuw5fcF3kKBuzbE8j\r
+ VKMN8pLJ3Qg/pbA/mxxX0Jhsgw+HQnnkBzzK8+WmjCbh9bQi1lTnT0r7SQUBy8LoFOsh\r
+ JS1g==\r
+X-Received: by 10.152.120.35 with SMTP id kz3mr5432918lab.55.1370882988163;\r
+ Mon, 10 Jun 2013 09:49:48 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi.\r
+ [88.195.118.211])\r
+ by mx.google.com with ESMTPSA id x5sm5977938lbx.8.2013.06.10.09.49.46\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Mon, 10 Jun 2013 09:49:47 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 1/7] cli: add --duplicate=N option to notmuch search\r
+In-Reply-To: <871u8b11bh.fsf@qmul.ac.uk>\r
+References: <cover.1370775663.git.jani@nikula.org>\r
+ <61ed86f221d65b4dba438cbc2b4c5b77a484a534.1370775663.git.jani@nikula.org>\r
+ <871u8b11bh.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.15.2+179~g8952790 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 10 Jun 2013 19:49:42 +0300\r
+Message-ID: <87ppvt6hcp.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-Gm-Message-State:\r
+ ALoCoQmZUbdJ1BbvCmTk3yBlVq1+CXTstxdkeNwhMOz0lBs0cKov6Z0fCEoZVq1MXEw1zivZY+jA\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 10 Jun 2013 16:49:58 -0000\r
+\r
+On Sun, 09 Jun 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> Overall I like this series and am happy to give it a +1 as is but have a\r
+> few comments which might be worth considering.\r
+>\r
+> Is the order of filenames clear? eg is it the order that notmuch new met\r
+> them? In particular is duplicate=1 the oldest and duplicate=N the\r
+> newest? If so that might be worth mentioning in the manpage.\r
+\r
+AFAICT it's the order in which notmuch new encountered them. Which may\r
+change if the user rebuilds the database. Which is why I intentionally\r
+avoided making any promises about what the numbers mean.\r
+\r
+>\r
+> On Sun, 09 Jun 2013, Jani Nikula <jani@nikula.org> wrote:\r
+>> Effective with --output=files, output the Nth filename associated with\r
+>> each message matching the query (N is 0-based). If N is equal to or\r
+>> greater than the number of files associated with the message, don't\r
+>> print anything.\r
+>> ---\r
+>> notmuch-search.c | 18 ++++++++++++------\r
+>> 1 file changed, 12 insertions(+), 6 deletions(-)\r
+>>\r
+>> diff --git a/notmuch-search.c b/notmuch-search.c\r
+>> index 4323201..196934b 100644\r
+>> --- a/notmuch-search.c\r
+>> +++ b/notmuch-search.c\r
+>> @@ -177,7 +177,8 @@ do_search_messages (sprinter_t *format,\r
+>> notmuch_query_t *query,\r
+>> output_t output,\r
+>> int offset,\r
+>> - int limit)\r
+>> + int limit,\r
+>> + int dupe)\r
+>> {\r
+>> notmuch_message_t *message;\r
+>> notmuch_messages_t *messages;\r
+>> @@ -206,14 +207,17 @@ do_search_messages (sprinter_t *format,\r
+>> message = notmuch_messages_get (messages);\r
+>> \r
+>> if (output == OUTPUT_FILES) {\r
+>> + int j;\r
+>> filenames = notmuch_message_get_filenames (message);\r
+>> \r
+>> - for (;\r
+>> + for (j = 1;\r
+>> notmuch_filenames_valid (filenames);\r
+>> - notmuch_filenames_move_to_next (filenames))\r
+>> + notmuch_filenames_move_to_next (filenames), j++)\r
+>> {\r
+>> - format->string (format, notmuch_filenames_get (filenames));\r
+>> - format->separator (format);\r
+>> + if (dupe < 0 || dupe == j) {\r
+>> + format->string (format, notmuch_filenames_get (filenames));\r
+>> + format->separator (format);\r
+>\r
+> Is it deliberate that dupe == 0 is not covered? If my newest oldest\r
+> thing above is correct then maybe dupe == 0 could be the all option +N\r
+> the Nth oldest and -N the Nth newest. This may be not-trivial enough\r
+> it's not worth doing.\r
+\r
+See my answer above. We can do this later if we decide it's worth the\r
+trouble.\r
+\r
+I don't check for 0 because it doesn't match anything. Similarly for\r
+values < 0.\r
+\r
+>\r
+>> + }\r
+>> }\r
+>> \r
+>> notmuch_filenames_destroy( filenames );\r
+>> @@ -303,6 +307,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+>> int offset = 0;\r
+>> int limit = -1; /* unlimited */\r
+>> int exclude = EXCLUDE_TRUE;\r
+>> + int dupe = -1;\r
+>> unsigned int i;\r
+>> \r
+>> enum {\r
+>> @@ -339,6 +344,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+>> { 0, 0 } } },\r
+>> { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+>> { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 },\r
+>> + { NOTMUCH_OPT_INT, &dupe, "duplicate", 'D', 0 },\r
+>> { 0, 0, 0, 0, 0 }\r
+>> };\r
+>> \r
+>> @@ -424,7 +430,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+>> break;\r
+>> case OUTPUT_MESSAGES:\r
+>> case OUTPUT_FILES:\r
+>> - ret = do_search_messages (format, query, output, offset, limit);\r
+>> + ret = do_search_messages (format, query, output, offset, limit, dupe);\r
+>\r
+> Should there be an error message if duplicate=x is chosen with\r
+> output!=files?\r
+\r
+I avoided adding checks upon checks, complicating the code, because\r
+there's no harm in allowing it. Matter of taste I suppose.\r
+\r
+Thanks for your comments.\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+>\r
+>> break;\r
+>> case OUTPUT_TAGS:\r
+>> ret = do_search_tags (notmuch, format, query);\r
+>> -- \r
+>> 1.7.10.4\r
+>>\r
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r