From a70697d1224cbb13dae99a50238e62650eee587c Mon Sep 17 00:00:00 2001 From: cos Date: Tue, 26 Jul 2022 13:03:57 +0200 Subject: Hack up message list to be sorted ascending By default aerc is designed to revert sorting of the message list in descending order. It's some kind of yolo thing? Possibly an attempt to cater to Outlook and Gmail users who never ever act on messages, but merely read the latest arrivals and leave them in the INBOX. There is a sort command as well as a sort config option, but they silently do not work with imap. According to #aerc on Libera.chat it should work with other email storage methods, but I haven't tried. When aerc is fetching the list of messages, it is done by first sending a 'UID THREAD REFERENCES "UTF-8" (ALL)' to the server, and then proceeding to actually fetch messages in sane order. The reverse happens later (in files modified by this commit). Supposedly reversing of order with other backends are done once while building the data structure, and is then reversed again when traversing it. One could have the idea of doing the same with imap, but that is an impossible (or at least impractical) thought to consider, since the imap grammar does not support combining threaded search and reversed sorting if I understand [rfc5256s5][] correctly. This patch merely fixes up aerc to be useful to me. Please approach me on Libera.chat for discussing a proper fix. I'm known as |cos| there. [rfc5256s5]: https://datatracker.ietf.org/doc/html/rfc5256#section-5 --- lib/msgstore.go | 2 +- widgets/msglist.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/msgstore.go b/lib/msgstore.go index a54b20b..4aaad82 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -491,7 +491,7 @@ func (store *MessageStore) Uids() []uint32 { func (store *MessageStore) Selected() *models.MessageInfo { uids := store.Uids() - idx := len(uids) - store.selected - 1 + idx := store.selected if len(uids) == 0 || idx < 0 || idx >= len(uids) { return nil } diff --git a/widgets/msglist.go b/widgets/msglist.go index e9603ca..395fb54 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -92,7 +92,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) { threads := store.Threads counter := len(store.Uids()) - for i := len(threads) - 1; i >= 0; i-- { + for i := 0; i < len(threads); i++ { var lastSubject string threads[i].Walk(func(t *types.Thread, _ int, currentErr error) error { if currentErr != nil { -- cgit v1.2.3