From: Tomi Ollila Date: Tue, 28 Oct 2014 21:36:58 +0000 (+0200) Subject: Re: [PATCH] Avoid empty thread names if possible. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b68a19d40a3bce859a590573394aeaaac890f0ad;p=notmuch-archives.git Re: [PATCH] Avoid empty thread names if possible. --- diff --git a/31/cbd163e1db2b589a085f022efbf18c94d7b277 b/31/cbd163e1db2b589a085f022efbf18c94d7b277 new file mode 100644 index 000000000..a41938085 --- /dev/null +++ b/31/cbd163e1db2b589a085f022efbf18c94d7b277 @@ -0,0 +1,113 @@ +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 F3452431FBF + for ; Tue, 28 Oct 2014 14:37:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +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 5EL5BjWDSZRZ for ; + Tue, 28 Oct 2014 14:37:12 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 8CECC431FB6 + for ; Tue, 28 Oct 2014 14:37:12 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 4B3B6100051; + Tue, 28 Oct 2014 23:36:58 +0200 (EET) +From: Tomi Ollila +To: Jesse Rosenthal , notmuch@notmuchmail.org +Subject: Re: [PATCH] Avoid empty thread names if possible. +In-Reply-To: <87oatnakqy.fsf@jhu.edu> +References: <87oatnakqy.fsf@jhu.edu> +User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Tue, 28 Oct 2014 21:37:21 -0000 + +On Tue, Oct 07 2014, Jesse Rosenthal wrote: + +> Currently the thread is named based on either the oldest or newest +> matching message (depending on the search order). If this message has +> an empty subject, though, the thread will show up with an empty +> subject in the search results. (See the thread starting with +> `id:1412371140-21051-1-git-send-email-david@tethera.net` for an +> example.) +> +> This patch changes the behavior to name based on the oldest/newest +> matching non-empty subject. This is particularly helpful for patchsets. +> If the only subjects are empty, the thread subject will still be empty. +> +> Signed-off-by: Jesse Rosenthal +> --- +> lib/thread.cc | 6 ++++-- +> 1 file changed, 4 insertions(+), 2 deletions(-) +> +> diff --git a/lib/thread.cc b/lib/thread.cc +> index 8922403..ea10295 100644 +> --- a/lib/thread.cc +> +++ b/lib/thread.cc +> @@ -348,18 +348,20 @@ _thread_add_matched_message (notmuch_thread_t *thread, +> { +> time_t date; +> notmuch_message_t *hashed_message; +> + const char *cur_subject; +> +> date = notmuch_message_get_date (message); +> + cur_subject = notmuch_thread_get_subject (thread); +> +> if (date < thread->oldest || ! thread->matched_messages) { +> thread->oldest = date; +> - if (sort == NOTMUCH_SORT_OLDEST_FIRST) +> + if (sort == NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0) + +IMO it is a bit silly to scan through the whole string and use the return +value of 0 (vs != 0) to have effect. we should probably have something like +#define EMPTY_STRING(s) ((s)[0] == '\0') +and use that instead. + +Also, to keep promise, mentioning 'patch' in commit message referring to +the change introduced does IMO also look silly :D + +Tomi + +> _thread_set_subject_from_message (thread, message); +> } +> +> if (date > thread->newest || ! thread->matched_messages) { +> thread->newest = date; +> - if (sort != NOTMUCH_SORT_OLDEST_FIRST) +> + if (sort != NOTMUCH_SORT_OLDEST_FIRST || strlen(cur_subject) == 0) +> _thread_set_subject_from_message (thread, message); +> } +> +> -- +> 2.1.2 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch