pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
697 stars 165 forks source link

Sort oldest first by newest email in thread #1609

Closed moridius closed 2 months ago

moridius commented 1 year ago

Is your feature request related to a problem? Please describe. I use

search_threads_sort_order = oldest_first

in config to have the newest mails on the bottom. Unfortunately this sorts by the date of the oldest message in a thread. If someone replies to a three weeks old message the thread is not shown at the bottom where I expect the new mails to be.

Describe the solution you'd like I would like a configuration option to sort "oldest_first_by_newest_message" or similar. I tinkered with the source code a bit. If I hardcode "reverse = True" on top of rebuild() in buffers/search.py I get exactly what I want. However, there might be side effects I don't see yet.

Describe alternatives you've considered I tried sorting by newest_first but that feels unnatural as in every log file or messenger the new stuff is at the bottom.

Additional context

pazz commented 2 months ago

We use a call to the notmuch library to look up messages/threads and I think that notmuch only has one option to affect both the order of threads and in it, which message is considered for the "date of the thread". CF man notmuch-search:

...
       --sort=(newest-first|oldest-first)
              This option can be used to present results in either chronological order (old‐
              est-first) or reverse chronological order (newest-first).

              Note:  The thread order will be distinct between these two options (beyond be‐
              ing simply reversed). When sorting by oldest-first the threads will be  sorted
              by  the  oldest  message  in each thread, but when sorting by newest-first the
              threads will be sorted by the newest message in each thread.

              By default, results will be displayed in reverse  chronological  order,  (that
              is, the newest results will be displayed first).

Curiously, the library (and the alot config you use above) seems to allow a third option: message_id, which is not documented on the manpage. Perhaps this is what you want (in combination with reverse)?

Either way, this does not seem actionable for us building the UI around notmuch. Feel free to open a PR to improve the docs around this if you can. Cheers