diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-07-14 20:37:31 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-07-16 10:12:56 +0200 |
commit | 94b1c778dbe691a75b0d918e9c40cc34f8523768 (patch) | |
tree | d3af4065a69f0cf710bde408f0eee8bfdc9dac6e | |
parent | c2bcc4bde8b8266d63d447bbfa46acc528ad7dfd (diff) | |
download | aerc-94b1c778dbe691a75b0d918e9c40cc34f8523768.tar.gz |
commands: add :fold and :unfold for thread folding
Add the :fold and :unfold commands to perform thread folding. They only
work on the selected message. Add vim-like bindings.
Fixes: https://todo.sr.ht/~rjarry/aerc/148
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: inwit <inwit@sindominio.net>
-rw-r--r-- | commands/msg/fold.go | 49 | ||||
-rw-r--r-- | config/binds.conf | 2 |
2 files changed, 51 insertions, 0 deletions
diff --git a/commands/msg/fold.go b/commands/msg/fold.go new file mode 100644 index 00000000..14d00f17 --- /dev/null +++ b/commands/msg/fold.go @@ -0,0 +1,49 @@ +package msg + +import ( + "errors" + "fmt" + "strings" + + "git.sr.ht/~rjarry/aerc/lib/ui" + "git.sr.ht/~rjarry/aerc/widgets" +) + +type Fold struct{} + +func init() { + register(Fold{}) +} + +func (Fold) Aliases() []string { + return []string{"fold", "unfold"} +} + +func (Fold) Complete(aerc *widgets.Aerc, args []string) []string { + return nil +} + +func (Fold) Execute(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return fmt.Errorf("Usage: %s", args[0]) + } + h := newHelper(aerc) + store, err := h.store() + if err != nil { + return err + } + + msg := store.Selected() + if msg == nil { + return errors.New("No message selected") + } + + switch strings.ToLower(args[0]) { + case "fold": + err = store.Fold(msg.Uid) + case "unfold": + err = store.Unfold(msg.Uid) + } + ui.Invalidate() + return err +} diff --git a/config/binds.conf b/config/binds.conf index fbc157b3..3d84ea14 100644 --- a/config/binds.conf +++ b/config/binds.conf @@ -41,6 +41,8 @@ v = :mark -t<Enter> V = :mark -v<Enter> T = :toggle-threads<Enter> +zc = :fold<Enter> +zo = :unfold<Enter> <Enter> = :view<Enter> d = :prompt 'Really delete this message?' 'delete-message'<Enter> |