From: Michal Sojka Date: Mon, 3 Nov 2014 21:39:26 +0000 (+0100) Subject: Re: [PATCH v6 6/7] cli: search: Add --output=count X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=272f6da46bbebaf032527c6ee85be4b1c33e5e27;p=notmuch-archives.git Re: [PATCH v6 6/7] cli: search: Add --output=count --- diff --git a/4b/39c717d2695f210ae3d993fd2f6a89b048de44 b/4b/39c717d2695f210ae3d993fd2f6a89b048de44 new file mode 100644 index 000000000..f67db698e --- /dev/null +++ b/4b/39c717d2695f210ae3d993fd2f6a89b048de44 @@ -0,0 +1,190 @@ +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 BF261431FD9 + for ; Mon, 3 Nov 2014 13:39:44 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[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 r7E847DyzHOT for ; + Mon, 3 Nov 2014 13:39:36 -0800 (PST) +Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) + by olra.theworths.org (Postfix) with ESMTP id 681AF431FAE + for ; Mon, 3 Nov 2014 13:39:36 -0800 (PST) +Received: from localhost (unknown [192.168.200.7]) + by max.feld.cvut.cz (Postfix) with ESMTP id E5D995CCFDD; + Mon, 3 Nov 2014 22:39:33 +0100 (CET) +X-Virus-Scanned: IMAP STYX AMAVIS +Received: from max.feld.cvut.cz ([192.168.200.1]) + by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, + port 10044) + with ESMTP id UWUrhsGvS0uK; Mon, 3 Nov 2014 22:39:32 +0100 (CET) +Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) + by max.feld.cvut.cz (Postfix) with ESMTP id F34BB5CCFE2; + Mon, 3 Nov 2014 22:39:31 +0100 (CET) +Received: from wsh by steelpick.2x.cz with local (Exim 4.84) + (envelope-from ) + id 1XlPLS-0006jb-28; Mon, 03 Nov 2014 22:39:26 +0100 +From: Michal Sojka +To: Tomi Ollila , + Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v6 6/7] cli: search: Add --output=count +In-Reply-To: +References: <1414792441-29555-1-git-send-email-sojkam1@fel.cvut.cz> + <1414792441-29555-7-git-send-email-sojkam1@fel.cvut.cz> + <87r3xnu3dn.fsf@qmul.ac.uk> <87bnoqbexm.fsf@steelpick.2x.cz> + <87d2963q87.fsf@qmul.ac.uk> + + +User-Agent: Notmuch/0.18.2+157~ga00d359 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Mon, 03 Nov 2014 22:39:26 +0100 +Message-ID: <87r3xk9d69.fsf@steelpick.2x.cz> +MIME-Version: 1.0 +Content-Type: text/plain +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, 03 Nov 2014 21:39:44 -0000 + +Hi Tomi, + +On Mon, Nov 03 2014, Tomi Ollila wrote: +> On Sun, Nov 02 2014, Michal Sojka wrote: +> +>> On 2. listopadu 2014 10:29:28 CET, Mark Walters wrote: +>>> +>>>Hi +>>> +>>>On Sun, 02 Nov 2014, Michal Sojka wrote: +>>>> On Sat, Nov 01 2014, Mark Walters wrote: +>>>>> On Fri, 31 Oct 2014, Michal Sojka wrote: +>>>>>> This output can be used with --output=recipients or --output=sender +>>>>>> and in addition to the addresses, it prints how many times was each +>>>>>> address encountered during search. +>>>>> +>>>>> Hi +>>>>> +>>>>> I have a couple comments on this patch. +>>>>> +>>>>>> --- +>>>>>> completion/notmuch-completion.bash | 2 +- +>>>>>> completion/notmuch-completion.zsh | 2 +- +>>>>>> doc/man1/notmuch-search.rst | 9 +++++-- +>>>>>> notmuch-search.c | 51 +>>>++++++++++++++++++++++++++++++++------ +>>>>>> 4 files changed, 52 insertions(+), 12 deletions(-) +>>>>>> +>>>>>> diff --git a/completion/notmuch-completion.bash +>>>b/completion/notmuch-completion.bash +>>>>>> index cfbd389..39cd829 100644 +>>>>>> --- a/completion/notmuch-completion.bash +>>>>>> +++ b/completion/notmuch-completion.bash +>>>>>> @@ -294,7 +294,7 @@ _notmuch_search() +>>>>>> return +>>>>>> ;; +>>>>>> --output) +>>>>>> - COMPREPLY=( $( compgen -W "summary threads messages files +>>>tags sender recipients" -- "${cur}" ) ) +>>>>>> + COMPREPLY=( $( compgen -W "summary threads messages files +>>>tags sender recipients count" -- "${cur}" ) ) +>>>>>> return +>>>>>> ;; +>>>>>> --sort) +>>>>>> diff --git a/completion/notmuch-completion.zsh +>>>b/completion/notmuch-completion.zsh +>>>>>> index 3e52a00..d7e5a5e 100644 +>>>>>> --- a/completion/notmuch-completion.zsh +>>>>>> +++ b/completion/notmuch-completion.zsh +>>>>>> @@ -53,7 +53,7 @@ _notmuch_search() +>>>>>> '--max-threads=[display only the first x threads from the +>>>search results]:number of threads to show: ' \ +>>>>>> '--first=[omit the first x threads from the search +>>>results]:number of threads to omit: ' \ +>>>>>> '--sort=[sort results]:sorting:((newest-first\:"reverse +>>>chronological order" oldest-first\:"chronological order"))' \ +>>>>>> - '--output=[select what to output]:output:((summary threads +>>>messages files tags sender recipients))' +>>>>>> + '--output=[select what to output]:output:((summary threads +>>>messages files tags sender recipients count))' +>>>>>> } +>>>>>> +>>>>>> _notmuch() +>>>>>> diff --git a/doc/man1/notmuch-search.rst +>>>b/doc/man1/notmuch-search.rst +>>>>>> index 42f17e4..ec89200 100644 +>>>>>> --- a/doc/man1/notmuch-search.rst +>>>>>> +++ b/doc/man1/notmuch-search.rst +>>>>>> @@ -96,9 +96,14 @@ Supported options for **search** include +>>>>>> Like **sender** but for addresses from *To*, *Cc* and +>>>>>> *Bcc* headers. +>>>>>> +>>>>>> + **count** +>>>>>> + Can be used in combination with **sender** or +>>>>>> + **recipients** to print the count of how many times was +>>>>>> + the address encountered during search. +>>>>>> + +>>>>>> This option can be given multiple times to combine different +>>>>>> - outputs. Currently, this is only supported for **sender** and +>>>>>> - **recipients** outputs. +>>>>>> + outputs. Currently, this is only supported for **sender**, +>>>>>> + **recipients** and **count** outputs. +>>>>> +>>>>> It might be worth saying that the results will be slower if count is +>>>>> specified. +>>>> +>>>> I wrote something like this in +>>>> id:1414889400-30977-10-git-send-email-sojkam1@fel.cvut.cz. +>>>> +>>>>> +>>>>>> ``--sort=``\ (**newest-first**\ \|\ **oldest-first**) +>>>>> +>>>>> I think sort works as expected if count is not specified, but does +>>>not +>>>>> with count. +>>>> +>>>> Agreed. +>>>> +>>>>> Maybe count can be done by doing two passes? +>>>> +>>>> What do you mean by pass? +>>> +>>>I mean iterating through the messages twice: so the first time would +>>>fill in the count in the hash map, and the second iteration would print +>>>the addresses. +>> +>> That's what the patch does. Only the second time it iterates the hash. +> +> Sorry +> +> And we loose the order ? (or not ?) do we have "orderedhash" there... +> I'd like to save the order + +What would be the use case? + +If you really want to preserve the order, we could save a sequence +number in mailbox_t and sort the hash table entries before printing. But +this could be implemented later and enabled by a special command line +option. notmuch search --output=tags does not preserve order either. + +> (but that is not so important) -- but more importantly, are tests +> robusts --- ah there is sort -n in the test... + +Yes. + +-Michal