From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id ECA27431FB6 for ; Tue, 7 Oct 2014 09:49:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.026 X-Spam-Level: X-Spam-Status: No, score=-1.026 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3, RDNS_NONE=1.274] 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 vAh0fxHEIS8B for ; Tue, 7 Oct 2014 09:48:55 -0700 (PDT) Received: from smtpauth.johnshopkins.edu (unknown [162.129.8.150]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 27EDF431FAF for ; Tue, 7 Oct 2014 09:48:55 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.04,671,1406606400"; d="scan'208";a="99715741" Received: from guppy.hwcampus.jhu.edu (HELO localhost) ([10.161.32.234]) by ipex0.johnshopkins.edu with ESMTP/TLS/AES128-SHA; 07 Oct 2014 12:48:53 -0400 From: Jesse Rosenthal To: notmuch@notmuchmail.org Subject: [PATCH] Avoid empty thread names if possible. Date: Tue, 7 Oct 2014 12:35:44 -0400 Message-ID: <87oatnakqy.fsf@jhu.edu> 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, 07 Oct 2014 16:49:04 -0000 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) _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