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 D17D44196F0 for ; Thu, 8 Apr 2010 23:07:31 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.5 X-Spam-Level: X-Spam-Status: No, score=-0.5 tagged_above=-999 required=5 tests=[BAYES_05=-0.5] 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 FSO61bAfg+kS for ; Thu, 8 Apr 2010 23:07:30 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 86D3E431FC1 for ; Thu, 8 Apr 2010 23:07:30 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id B6D7019F33A1; Fri, 9 Apr 2010 08:07:29 +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 8rWkfX9QYHWT; Fri, 9 Apr 2010 08:07:28 +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 6C7A819F3331; Fri, 9 Apr 2010 08:07:28 +0200 (CEST) Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 66CB6FA003; Fri, 9 Apr 2010 08:07:28 +0200 (CEST) Received: from wsh by steelpick.2x.cz with local (Exim 4.71) (envelope-from ) id 1O07NH-0005ah-PQ; Fri, 09 Apr 2010 08:07:27 +0200 From: Michal Sojka To: Dirk Hohndel , notmuch Subject: Re: [RFC] reordering and cleanup of thread authors In-Reply-To: References: Date: Fri, 09 Apr 2010 08:07:27 +0200 Message-ID: <87zl1d5fc0.fsf@steelpick.2x.cz> 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: Fri, 09 Apr 2010 06:07:32 -0000 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. Hi Dirk, thanks for the patch. It is a very interesting feature. See my comments below. > > [...] > > +/* > + * 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? 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. -Michal > + /* we have to make changes, so let's get a temp copy */ > + authorscopy = strdup(thread->authors); > + if (authorscopy == NULL) > + return; > + /* nmstart is the offset into where the non-matched authors start */ > + nmstart = thread->nonmatched_authors - thread->authors; > + /* copy this author and add the "| " - the if clause above tells us there's more */ > + strncpy(thread->nonmatched_authors,author,author_len); > + strncpy(thread->nonmatched_authors+author_len,"| ",2); > + thread->nonmatched_authors += author_len+2; > + if (idx > 0) { > + /* we are actually moving authors around, not just changing the separator > + * first copy the authors that came BEFORE our author */ > + strncpy(thread->nonmatched_authors, authorscopy+nmstart, idx-2); > + /* finally, if there are authors AFTER our author, copy those */ > + if(author_len+nmstart+idx < authors_len) { > + strncpy(thread->nonmatched_authors + idx - 2,", ",2); > + strncpy(thread->nonmatched_authors + idx, authorscopy+nmstart + idx + author_len + 2, > + authors_len - (nmstart + idx + author_len + 2)); > + } > + } > + free(authorscopy); > + } else { > + thread->nonmatched_authors += author_len; > + } > + return; > +}