diff options
author | inwit <inwit@sindominio.net> | 2023-11-12 13:42:58 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-11-23 00:14:29 +0100 |
commit | 79940fe646153744ce428b08b8314e641d59293b (patch) | |
tree | 5df8138cb63f3b26ac94a36860f07553c51368ee /commands/msg | |
parent | cb48d5b547e53125857af154b3b0bb921030ba88 (diff) | |
download | aerc-79940fe646153744ce428b08b8314e641d59293b.tar.gz |
fold: add an option to fold/unfold all threads
Commands :fold/:unfold act upon a single thread. Add an option to both
commands allowing the user to fold/unfold all displayed threads.
Signed-Off-By: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'commands/msg')
-rw-r--r-- | commands/msg/fold.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/commands/msg/fold.go b/commands/msg/fold.go index f3f55871..a05d71ca 100644 --- a/commands/msg/fold.go +++ b/commands/msg/fold.go @@ -2,12 +2,12 @@ package msg import ( "errors" - "strings" "git.sr.ht/~rjarry/aerc/lib/ui" ) type Fold struct { + All bool `opt:"-a"` Toggle bool `opt:"-t" aliases:"fold,unfold"` } @@ -26,12 +26,34 @@ func (f Fold) Execute(args []string) error { return err } + if f.All { + point := store.SelectedUid() + uids := store.Uids() + for _, uid := range uids { + t, err := store.Thread(uid) + if err == nil && t.Parent == nil { + switch args[0] { + case "fold": + err = store.Fold(uid, f.Toggle) + case "unfold": + err = store.Unfold(uid, f.Toggle) + } + } + if err != nil { + return err + } + } + store.Select(point) + ui.Invalidate() + return err + } + msg := store.Selected() if msg == nil { return errors.New("No message selected") } - switch strings.ToLower(args[0]) { + switch args[0] { case "fold": err = store.Fold(msg.Uid, f.Toggle) case "unfold": |