Sorting threads in NeoMutt

In NeoMutt, which I use for email, I wanted view email conversations (a “thread”) as a tree-like representation. This option can be enabled by sorting on threads. However, by default threads are sorted by their oldest message, which is the original email to which others started responding. This causes the unwanted behavior that new emails that belong to a thread to not show on top of my inbox, but instead are hidden somewhere deeper in my inbox, sorted at the date of the older original post. I did not quickly find people with similar wishes (and solution) on the internet, so I considered it potentially helpful to write down my solution here.

To solve this behavior, I defined a secondary sorting method. The primary sorting method is on threads, but I want threads themselves to be sorted based on the date of the newest message. Also, I still want to ensure that newest messages show up on top, and not on the bottom (this is the reverse of the default setting in NeoMutt). I achieved this by setting these variables in my neomuttrc:

set sort = threads 
set sort_aux = reverse-last-date-received

This produces a tree-like representation as such:

Example of a sorted thread in NeoMutt

Note that this is a very messy thread, where nobody cared to change the email title, and where multiple threads branch off from each other. Nevertheless, using NeoMutt with the thread sorting, I know exactly who responded to who.

Self portraits using stable diffusion <-- Latest

Selecting user commands in style (Python) <-- Next

Creating a PGP key, sending mail with GPG <-- Previous

Setting up your own tilde club (UNIX) <-- Random


Do you want to link a webmention to this page?
Provide the URL of your response for it to show up here.


profnof on Saturday, Nov 14, 2020:

Спасибо за информацию.

Edwin on Saturday, Nov 14, 2020
In reply to profnof

My pleasure

Le Chen on Friday, Mar 26, 2021:

Thank you for your trick. It solves my question.

Edwin on Friday, Mar 26, 2021
In reply to Le Chen

Glad to hear!

mariansam on Tuesday, Apr 20, 2021:

Wow, big thanks for this I had set sort = 'reverse-date' and I didn’t know about it. This solved my issue.

However, I’d love to see even my responses in the thread! Is that possible? Currently the received messages are in the INBOX mailbox and the sent messages are in the Sent mailbox. Is that something I have to change on the server side, or can neomutt deal with that?

contact: mariansam

Edwin on Wednesday, Apr 21, 2021
In reply to mariansam

Glad to hear it was useful! I’m afraid it’s really intended behavior to record incoming messages in INBOX and outgoing messages in SENT. Because people usually include the message they respond to in the reply itself, you effectively also have your own outgoing message in the inbox when the reply comes in. I did a quick Google search and only found ugly hacks. If you somehow would configure server side that sent messages stay in your own inbox, that would of course work… but I can’t imagine any service supporting this. I’m also curious if you know of any other client doing this :-)