unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: Jesse Rosenthal <jrosenthal@jhu.edu>, notmuch@notmuchmail.org
Subject: Re: [PATCH] Avoid empty thread names if possible.
Date: Wed, 29 Oct 2014 08:34:19 +0000	[thread overview]
Message-ID: <87tx2nuvec.fsf@qmul.ac.uk> (raw)
In-Reply-To: <87oatnakqy.fsf@jhu.edu>


Hi

On Tue, 07 Oct 2014, Jesse Rosenthal <jrosenthal@jhu.edu> 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.

I approve of the change in the output but I am unsure about the
implementation. It would be nice to have a clear rule about which
subject is taken. Eg: 

        if sort is oldest first then it is the subject of the oldest
        matching message with a non-empty subject. Similarly if sort
        is newest first.

Also, it would be nice if the implementation did not rely on what order
we call _thread_add_matched_message on the matching messages in the
thread. I think in some ways we already rely on the order (for the order
of the author list), but if you want to rely on the order here I think
it at least deserves a comment.

>
> Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>
> ---
>  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);
>      }

So looking at the above I think the oldest first gives the subject in
my suggestion above (since the messages are supplied in oldest first
order). But newest first may not: indeed if the subject starts out as
something and becomes empty then this will set the subject empty and
then leave it empty.

(Note _thread_set_subject_from_message calls notmuch_message_get_header
which returns an empty string "" if the subject line is empty or not
present).

Best wishes

Mark


>  
> -- 
> 2.1.2
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  parent reply	other threads:[~2014-10-29  8:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-07 16:35 [PATCH] Avoid empty thread names if possible Jesse Rosenthal
2014-10-08 15:40 ` Sergei Shilovsky
2014-10-28 17:44   ` Jani Nikula
2014-10-28 21:36 ` Tomi Ollila
2014-10-29 13:21   ` Jesse Rosenthal
2014-10-29  8:34 ` Mark Walters [this message]
2014-10-29 13:05   ` Jesse Rosenthal
2014-10-29 13:07   ` Jesse Rosenthal
2014-10-29 13:27     ` Jesse Rosenthal
2014-10-29 13:32     ` Tomi Ollila
2014-10-29 13:39   ` Jesse Rosenthal
2014-10-29 15:15     ` Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tx2nuvec.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=jrosenthal@jhu.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).