From 117f99e187e16086c1c43a03d640da3294e9e730 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Mon, 8 Aug 2022 22:21:45 +0200 Subject: mark: (un)mark message threads Mark or unmark the shown message threads. Threads must be available in the message store. Use the -T option for the mark or unmark commands. Can be used in combination with the toggle flag (-t). Signed-off-by: Koni Marti Acked-by: Robin Jarry --- commands/msg/mark.go | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'commands/msg/mark.go') diff --git a/commands/msg/mark.go b/commands/msg/mark.go index 939d456a..b5a228db 100644 --- a/commands/msg/mark.go +++ b/commands/msg/mark.go @@ -32,7 +32,7 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error { return err } marker := store.Marker() - opts, _, err := getopt.Getopts(args, "atvV") + opts, _, err := getopt.Getopts(args, "atvVT") if err != nil { return err } @@ -40,6 +40,7 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error { var toggle bool var visual bool var clearVisual bool + var thread bool for _, opt := range opts { switch opt.Option { case 'a': @@ -51,9 +52,23 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error { visual = true case 't': toggle = true + case 'T': + thread = true } } + if thread && len(store.Threads()) == 0 { + return fmt.Errorf("No threads found") + } + + if thread && all { + return fmt.Errorf("-a and -T are mutually exclusive") + } + + if thread && visual { + return fmt.Errorf("-v and -T are mutually exclusive") + } + switch args[0] { case "mark": if all && visual { @@ -77,7 +92,13 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error { marker.ToggleVisualMark(clearVisual) return nil default: - modFunc(selected.Uid) + if thread { + for _, uid := range store.SelectedThread().Root().Uids() { + modFunc(uid) + } + } else { + modFunc(selected.Uid) + } return nil } @@ -97,11 +118,17 @@ func (Mark) Execute(aerc *widgets.Aerc, args []string) error { marker.ClearVisualMark() return nil default: - marker.Unmark(selected.Uid) + if thread { + for _, uid := range store.SelectedThread().Root().Uids() { + marker.Unmark(uid) + } + } else { + marker.Unmark(selected.Uid) + } return nil } case "remark": - if all || visual || toggle { + if all || visual || toggle || thread { return fmt.Errorf("Usage: :remark") } marker.Remark() -- cgit