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 13798431FAF for ; Sun, 9 Jun 2013 13:23:01 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 8jBMmSTZU7YR for ; Sun, 9 Jun 2013 13:22:51 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id EED08431FAE for ; Sun, 9 Jun 2013 13:22:50 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1Ulm8S-00053s-TJ; Sun, 09 Jun 2013 21:22:47 +0100 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1Ulm8S-0005jS-IL; Sun, 09 Jun 2013 21:22:44 +0100 From: Mark Walters To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH v2 1/7] cli: add --duplicate=N option to notmuch search In-Reply-To: <61ed86f221d65b4dba438cbc2b4c5b77a484a534.1370775663.git.jani@nikula.org> References: <61ed86f221d65b4dba438cbc2b4c5b77a484a534.1370775663.git.jani@nikula.org> User-Agent: Notmuch/0.15.2+171~ge2f30a2 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sun, 09 Jun 2013 21:22:42 +0100 Message-ID: <871u8b11bh.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: 5887149924c26243538d1a921c1476d2 (of first 20000 bytes) X-SpamAssassin-Score: -0.0 X-SpamAssassin-SpamBar: / X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -0.0 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.0 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sun, 09 Jun 2013 20:23:01 -0000 Overall I like this series and am happy to give it a +1 as is but have a few comments which might be worth considering. Is the order of filenames clear? eg is it the order that notmuch new met them? In particular is duplicate=1 the oldest and duplicate=N the newest? If so that might be worth mentioning in the manpage. On Sun, 09 Jun 2013, Jani Nikula wrote: > 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 4323201..196934b 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); Is it deliberate that dupe == 0 is not covered? If my newest oldest thing above is correct then maybe dupe == 0 could be the all option +N the Nth oldest and -N the Nth newest. This may be not-trivial enough it's not worth doing. > + } > } > > notmuch_filenames_destroy( filenames ); > @@ -303,6 +307,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 { > @@ -339,6 +344,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 } > }; > > @@ -424,7 +430,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); Should there be an error message if duplicate=x is chosen with output!=files? Best wishes Mark > break; > case OUTPUT_TAGS: > ret = do_search_tags (notmuch, format, query); > -- > 1.7.10.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch