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 6140E4196F0 for ; Fri, 9 Apr 2010 18:54:08 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] 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 y-ZgeBoOYSjB for ; Fri, 9 Apr 2010 18:54:07 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 1B766431FC1 for ; Fri, 9 Apr 2010 18:54:07 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id 0C39D19F341A; Sat, 10 Apr 2010 03:54:06 +0200 (CEST) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id PkPPgZssXM8R; Sat, 10 Apr 2010 03:54:04 +0200 (CEST) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id A03D519F3411; Sat, 10 Apr 2010 03:54:04 +0200 (CEST) Received: from wsheee.localdomain (unknown [213.29.198.144]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 2BCACFA003; Sat, 10 Apr 2010 03:54:00 +0200 (CEST) Received: from wsh by wsheee.localdomain with local (Exim 4.69) (envelope-from ) id 1O0PtX-0001UM-PY; Sat, 10 Apr 2010 03:53:59 +0200 From: Michal Sojka To: Dirk Hohndel , notmuch Subject: Re: [RFC] reordering and cleanup of thread authors In-Reply-To: References: <87zl1d5fc0.fsf@steelpick.2x.cz> Date: Sat, 10 Apr 2010 03:53:59 +0200 Message-ID: <87aatcysw8.fsf@wsheee.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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, 10 Apr 2010 01:54:08 -0000 On Fri, 09 Apr 2010, Dirk Hohndel wrote: > On Fri, 09 Apr 2010 08:07:27 +0200, Michal Sojka wrote: > > On Wed, 07 Apr 2010, Dirk Hohndel wrote: > > > > > > This is based in part on some discussion on IRC today. > > > When a thread is displayed in the search results, previously the authors > > > were always displayed in chronological order. But if only part of the > > > thread matches the query, that may or may not be the intuitive thing to > > > do. > > > > thanks for the patch. It is a very interesting feature. > > Thanks - I've been using it for a few days now and am fairly happy with > it. > > > > > > > +/* > > > + * move authors of matched messages in the thread to > > > + * the front of the authors list, but keep them in > > > + * oldest first order within their group > > > + */ > > > +static void > > > +_thread_move_matched_author (notmuch_thread_t *thread, > > > + const char *author) > > > +{ > > > + char *authorscopy; > > > + char *currentauthor; > > > + int idx,nmstart,author_len,authors_len; > > > + > > > + if (thread->authors == NULL) > > > + return; > > > + if (thread->nonmatched_authors == NULL) > > > + thread->nonmatched_authors = thread->authors; > > > + author_len = strlen(author); > > > + authors_len = strlen(thread->authors); > > > + if (author_len == authors_len) { > > > + /* just one author */ > > > + thread->nonmatched_authors += author_len; > > > + return; > > > + } > > > + currentauthor = strcasestr(thread->authors, author); > > > + if (currentauthor == NULL) > > > + return; > > > + idx = currentauthor - thread->nonmatched_authors; > > > + if (idx < 0) { > > > + /* already among matched authors */ > > > + return; > > > + } > > > + if (thread->nonmatched_authors + author_len < thread->authors + authors_len) { > > > > What does the above condition exactly mean? > > Eh - it's ugly. > > thread->authors + authors_len points to the trailing '\0' of the list of > all my authors. At this point in the code we know that the current > position of this author is at or after nonmatched_authors. So if > nonmatched_authors + author_len is less than the end of the all authors > that means that there was another author in the list behind this one - > and we need to move things around. > > In the else clause we just move the pointer to nonmatched_authors to the > end of this author. > > So yeah, ugly, should be rewritten to make it easier to understand (or > at least commented better). > > > I was not able to decode it > > and it seems to be wrong. I expect that the "|" is used to delimit > > matched and non-matched authors. If I run notmuch search > > thread:XXXXXXXXXXXXXXXX, which matches all messages in the thread, I see > > all authors delimited by "|", which I consider wrong. > > Why do you think it's wrong? Because I thought, that | was used as a delimiter between the two parts of the list and not as a marker of matched authors. > It's consistent. The thing that I actually DISlike about the current > solution is that the last author has no delimiter (since there's no > trailing ',' in the list and I didn't want to realloc the space for > the authors string). So you can't tell with one glance if all authors > match or all but the last one match. I haven't come up with a better > visual way to indicate this... I think that using | as a separator would help here. Let's say that initially we have "Matched Author, Non Matched, Matched Again" we can tranform this to "Matched Author, Matched Again| Non Matched". This way, the length of the string remains the same. If there is no | after transformation, we know that all authors matched because there is always at least one mathed author in the search results. -Michal