diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-08-08 22:21:45 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-22 09:30:37 +0200 |
commit | 117f99e187e16086c1c43a03d640da3294e9e730 (patch) | |
tree | 7cec6d937e31fea03d6244f97eba944ac44e5c40 /commands/msg/mark.go | |
parent | b12dd9f9263f7c2cf2f91bc3f6f5549ee0165cb1 (diff) | |
download | aerc-117f99e187e16086c1c43a03d640da3294e9e730.tar.gz |
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 <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg/mark.go')
-rw-r--r-- | commands/msg/mark.go | 35 |
1 files changed, 31 insertions, 4 deletions
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() |