aerc/commands/msg/toggle-threads.go
Koni Marti 7811620eb8 threading: implement on-the-fly message threading
implement message threading on the message store level using the
jwz algorithm. Build threads on-the-fly when new message headers arrive.

Use the references header to create the threads and the in-reply-to
header as a fall-back option in case no references header is present.

Does not run when the worker provides its own threading (e.g. imap
server threads).

Include only those message headers that have been fetched and are
stored in the message store.

References: https://www.jwz.org/doc/threading.html
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Tested-by: akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-02-24 13:00:12 +01:00

40 lines
684 B
Go

package msg
import (
"errors"
"git.sr.ht/~rjarry/aerc/widgets"
)
type ToggleThreads struct{}
func init() {
register(ToggleThreads{})
}
func (ToggleThreads) Aliases() []string {
return []string{"toggle-threads"}
}
func (ToggleThreads) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}
func (ToggleThreads) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: toggle-threads")
}
h := newHelper(aerc)
acct, err := h.account()
if err != nil {
return err
}
store, err := h.store()
if err != nil {
return err
}
store.SetBuildThreads(!store.BuildThreads())
acct.Messages().Invalidate()
return nil
}