From 38205ebdee627977ab91be4ffa2b3e2e0b7e0e77 Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Wed, 22 Apr 2015 04:01:13 +0200 Subject: [PATCH] Re: notmuch_thread_get_authors --- 9e/1b95c41babe653a92c809cd4f9868024300133 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 9e/1b95c41babe653a92c809cd4f9868024300133 diff --git a/9e/1b95c41babe653a92c809cd4f9868024300133 b/9e/1b95c41babe653a92c809cd4f9868024300133 new file mode 100644 index 000000000..36ab1a297 --- /dev/null +++ b/9e/1b95c41babe653a92c809cd4f9868024300133 @@ -0,0 +1,128 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id E09966DE1A2E + for ; Tue, 21 Apr 2015 19:01:19 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.465 +X-Spam-Level: +X-Spam-Status: No, score=-0.465 tagged_above=-999 required=5 tests=[AWL=0.355, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + SPF_PASS=-0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Q_Qu5auWWvsP for ; + Tue, 21 Apr 2015 19:01:16 -0700 (PDT) +Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com + [209.85.218.46]) + by arlo.cworth.org (Postfix) with ESMTPS id 70EAA6DE17ED + for ; Tue, 21 Apr 2015 19:01:16 -0700 (PDT) +Received: by oiko83 with SMTP id o83so167960094oik.1 + for ; Tue, 21 Apr 2015 19:01:14 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=mime-version:in-reply-to:references:date:message-id:subject:from:to + :cc:content-type; + bh=CqH9Q3ydLFV5U3QKFjKd0MHE8+RjQayFSkm/WjbBJrk=; + b=C/kW+SGwvWOzp5G43c2Lm8EsWTMFKx0WA6yeigsN+Ph7xJFqedvwzTCLgXeUtX1Uuu + tY4MKHXD0FBsYuc/P0ymQNHxn1qrrpS5QNyvqQbCH+mNICFD/C2+mi3GGGm+4jtyZxbb + /jgtTHnZAmujWbrLicIFWJfu7xsknDDWa38p2QD0KSYsHK88vpiYudYV/rVVuhcd/DN3 + h5D1Ch1NlUul60DviZU74d9DO3gR1MgUAbOevh6Jcchx1FOCK/IUSXgXKDeh+b6GUuW+ + RHIkN8BYDYLonVo+eohELB75nUokvzR91CGBnm2GM0RXzF9U4lD+hDWbyG4YH1E5SPDA + Dciw== +MIME-Version: 1.0 +X-Received: by 10.182.137.136 with SMTP id qi8mr20802764obb.51.1429668073833; + Tue, 21 Apr 2015 19:01:13 -0700 (PDT) +Received: by 10.202.216.5 with HTTP; Tue, 21 Apr 2015 19:01:13 -0700 (PDT) +In-Reply-To: <87lhhlhryd.fsf@csail.mit.edu> +References: + + <87618qfk5l.fsf@maritornes.cs.unb.ca> + + <87lhhlhryd.fsf@csail.mit.edu> +Date: Wed, 22 Apr 2015 04:01:13 +0200 +Message-ID: + +Subject: Re: notmuch_thread_get_authors +From: Ronny Chevalier +To: Austin Clements +Content-Type: text/plain; charset=UTF-8 +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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: Wed, 22 Apr 2015 02:01:20 -0000 + +On Wed, Apr 22, 2015 at 3:28 AM, Austin Clements + wrote: +> On Tue, 21 Apr 2015, Ronny Chevalier wrote: +>> On Tue, Apr 21, 2015 at 1:35 AM, David Bremner wrote: +>>> Ronny Chevalier writes: +>> Austin Clements wrote: +>>> And I think there's a fairly easy way to do it in C code that will +>>> also prevent library interface bloat: instead of introducing new +>>> library APIs to get at this information, just use the existing +>>> notmuch_thread_get_messages API and construct the matched and +>>> non-matched lists in the CLI. Doing it in the CLI wouldn't require +>>> the library to export yet another string list structure, which is +>>> always a huge pain (thanks C!), and wouldn't introduce more "helper" +>>> functions into the library API. +>> +>> I disagree with what Austin said. Because this does not solve the +>> issue at all (or I misunderstood). The issue is with the notmuch API, +>> if someone is using this library there no way it can parse properly +>> the authors. +>> In my case I am not using the CLI but the notmuch library, fixing this +>> in the CLI is just an hack, and it does not fix the issue for the +>> library users. +> +> My suggestion was in no way specific to the CLI. That was the context of +> the discussion at the time, but for the purposes of this discussion, the +> CLI is just another library user. + +Ok, sorry for misunderstanding. + +> +> You're completely right that there's no way to reliably parse the +> authors list returned by notmuch_thread_get_authors. So don't do +> that. Just use notmuch_thread_get_messages, walk the messages list, and +> build your own authors list. There's no need to introduce additional +> complexity and surface area into the library API for this specific use +> case (IMO, even notmuch_thread_get_authors shouldn't exist, but it's +> there for legacy reasons.) Then you can get author lists for matched, +> non-matched, matching a specific tag, just the to, just the from, counts +> of how many times each author appeared, whatever you want. +> + +Ok thanks! + +If I read the code correctly, _notmuch_thread_create in lib/thread.cc +process every message to get information like tags, subject and +authors. Since notmuch_thread_get_authors is here for legacy reasons, +would it be better to generate the list of authors only when requested +with notmuch_thread_get_authors (and cache the result of course)? +Because, new code will not use this and will do this work manually, +the generation of the list in intern consumes resources for nothing. + +>> Furthermore, I do not see why providing a string list NULL-terminated +>> in C is a huge pain? +> +> See the notmuch_tags_* and notmuch_filesnames_* APIs. Those are just +> string lists. +> +>> Otherwise, I agree with Mark Walters comments on the patch. +>> +>> If no one is working to fix this at the moment, I can send a patch? +>> +>> Ronny -- 2.26.2