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 DDE3C4196F3 for ; Fri, 23 Apr 2010 17:21:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.89 X-Spam-Level: X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01] autolearn=ham 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 f0rMPS1V1VLU; Fri, 23 Apr 2010 17:21:54 -0700 (PDT) Received: from yoom.home.cworth.org (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0BF5C431FC1; Fri, 23 Apr 2010 17:21:54 -0700 (PDT) Received: by yoom.home.cworth.org (Postfix, from userid 1000) id AABA7568DE4; Fri, 23 Apr 2010 17:21:53 -0700 (PDT) From: Carl Worth To: Dirk Hohndel , notmuch Subject: Re: [PATCH] Reordering of thread authors to list matching authors first In-Reply-To: References: <87zl1d5fc0.fsf@steelpick.2x.cz> <87aatcysw8.fsf@wsheee.localdomain> User-Agent: Notmuch/0.2-164-g57926bc (http://notmuchmail.org) Emacs/23.1.1 (i486-pc-linux-gnu) Date: Fri, 23 Apr 2010 17:21:53 -0700 Message-ID: <87hbn1og2m.fsf@yoom.home.cworth.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" 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 00:21:55 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable On Wed, 21 Apr 2010 20:58:27 -0700, Dirk Hohndel wr= ote: > 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 fr= om the > non-matching ones with a '|' instead of a ',' It seems a reasonable feature to me. Some notes on the patch: > +void > +notmuch_message_set_author (notmuch_message_t *message, > + const char *author) > +{ > + message->author =3D 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. > +/* 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 *auth= or); > + > +/* 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. > +/* > + * move authors of matched messages in the thread to=20 > + * 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. =2DCarl --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFL0jmh6JDdNq8qSWgRAhb6AKCijZXXjFjK0PlhlhzTMeyMUKZL+ACdH/Df jkwAfLTN/kl3TnNA19WmZTU= =Fi+A -----END PGP SIGNATURE----- --=-=-=--