aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinwit <inwit@sindominio.net>2023-11-12 13:42:58 +0100
committerRobin Jarry <robin@jarry.cc>2023-11-23 00:14:29 +0100
commit79940fe646153744ce428b08b8314e641d59293b (patch)
tree5df8138cb63f3b26ac94a36860f07553c51368ee
parentcb48d5b547e53125857af154b3b0bb921030ba88 (diff)
downloadaerc-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>
-rw-r--r--commands/msg/fold.go26
-rw-r--r--doc/aerc.1.scd7
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.