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 302C8431FC1 for ; Sat, 24 Apr 2010 10:35:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -4.2 X-Spam-Level: X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=unavailable 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 dLVku3CHUjZ6 for ; Sat, 24 Apr 2010 10:35:07 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by olra.theworths.org (Postfix) with ESMTP id CFF364196F2 for ; Sat, 24 Apr 2010 10:35:07 -0700 (PDT) Received: from localhost ([::1] helo=x200.gr8dns.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O5jFy-0006lt-MX; Sat, 24 Apr 2010 17:35:06 +0000 Received: by x200.gr8dns.org (Postfix, from userid 500) id 82FDCCC598; Sat, 24 Apr 2010 10:35:05 -0700 (PDT) From: Dirk Hohndel To: Carl Worth , notmuch Subject: Re: [PATCH] Reordering of thread authors to list matching authors first In-Reply-To: <87hbn1og2m.fsf@yoom.home.cworth.org> References: <87zl1d5fc0.fsf@steelpick.2x.cz> <87aatcysw8.fsf@wsheee.localdomain> <87hbn1og2m.fsf@yoom.home.cworth.org> User-Agent: Notmuch/0.2-187-g7c5f017 (http://notmuchmail.org) Emacs/23.1.1 (i386-redhat-linux-gnu) Date: Sat, 24 Apr 2010 10:35:05 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html 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: Sat, 24 Apr 2010 17:35:09 -0000 On Fri, 23 Apr 2010 17:21:53 -0700, Carl Worth wrote: > On Wed, 21 Apr 2010 20:58:27 -0700, Dirk Hohndel wrote: > > When displaying threads as result of a search it makes sense to list those > > authors first who match the search. The matching authors are separated from the > > non-matching ones with a '|' instead of a ',' > > It seems a reasonable feature to me. I switched back to origin/master to help get ready for 0.3 and tremendously miss this feature :-) > Some notes on the patch: > > > +void > > +notmuch_message_set_author (notmuch_message_t *message, > > + const char *author) > > +{ > > + message->author = talloc_strdup(message, author); > > + return; > > +} > > This is leaking any previously set author value, (admittedly, it's only > a "talloc leak" so it will still get cleaned up when the message is > cleaned up, but still. Fixed in forthcoming revision of this patch > > > +/* Set the author member of 'message' - this is the representation used > > + * when displaying the message > > + */ > > +void > > +notmuch_message_set_author (notmuch_message_t *message, const char *author); > > + > > +/* Get the author member of 'message' > > + */ > > +const char * > > +notmuch_message_get_author (notmuch_message_t *message); > > The notmuch.h file is our publicly installed header file for the library > interface. I don't think the feature here requires any new library > interface. Even if it did, we wouldn't want a public function like > set_author that could simply scramble internal state and change the > result of future calls to get_author. My mistake - moved them to notmuch-private.h > > +/* > > + * move authors of matched messages in the thread to > > + * the front of the authors list, but keep them in > > + * existing order within their group > > + */ > > +static void > > +_thread_move_matched_author (notmuch_thread_t *thread, > > + const char *author) > > The implementation here seems a bit fiddly. > > We already have two passes over the messages, (first all messages, and > then all matched messages). And we're currently calling add_author from > the first pass. > > How about simply calling a new add_matched_author from the second pass > which would look very much like the existing add_author. Then we could > change add_author to accumulate authors into an array rather than a > string. Then, finally, we would append any of these authors not already > in the matched_authors hash tabled onto the final string. > > That should be less code and easier to understand I think. > > I can take a whack at that later if you don't beat me to it. Maybe I'm misunderstanding your proposed algorithm - but it seems quite a bit more complicated than what I'm doing today... /D