diff options
-rw-r--r-- | commands/msg/fold.go | 26 | ||||
-rw-r--r-- | doc/aerc.1.scd | 7 |
2 files changed, 28 insertions, 5 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": diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index c34b3e7f..6214d02e 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -529,10 +529,11 @@ message list, the message in the message viewer, etc). *:toggle-threads* Toggles between message threading and the normal message list. -*:fold* [*-t*]++ -*:unfold* [*-t*] +*:fold* [*-at*]++ +*:unfold* [*-at*] Collapse or un-collapse the thread children of the selected message. - If the toggle flag *-t* is set, the folded status is changed. Folded + If the toggle flag *-t* is set, the folded status is changed. If the + *-a* flag is set, all threads in the current view are affected. Folded threads can be identified by _{{.Thread\*}}_ template attributes in *[ui].index-columns*. See *aerc-config*(5) and *aerc-templates*(7) for more details. |