diff options
author | Robin Jarry <robin@jarry.cc> | 2023-07-05 23:10:39 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-07-17 10:24:17 +0200 |
commit | 4c514ce4d15fd14cad528cf426bc3f853efe7f64 (patch) | |
tree | fa52247b470a6af233a6e242962ed20e4831a555 /commands/compose | |
parent | 11e5390fa0acbcc609ca177777548dd2d725afbc (diff) | |
download | aerc-4c514ce4d15fd14cad528cf426bc3f853efe7f64.tar.gz |
compose: allow changing edit-headers on the fly
Add -e|-E flags to all compose commands to allow switching between
edit-headers = true/false without restarting aerc.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'commands/compose')
-rw-r--r-- | commands/compose/edit.go | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/commands/compose/edit.go b/commands/compose/edit.go index 6f877346..1e8e0672 100644 --- a/commands/compose/edit.go +++ b/commands/compose/edit.go @@ -3,7 +3,9 @@ package compose import ( "errors" + "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~sircmpwn/getopt" ) type Edit struct{} @@ -21,14 +23,29 @@ func (Edit) Complete(aerc *widgets.Aerc, args []string) []string { } func (Edit) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) != 1 { - return errors.New("Usage: edit") - } composer, ok := aerc.SelectedTabContent().(*widgets.Composer) if !ok { return errors.New("only valid while composing") } - err := composer.ShowTerminal() + + editHeaders := config.Compose.EditHeaders + opts, optind, err := getopt.Getopts(args, "eE") + if err != nil { + return err + } + if len(args) != optind { + return errors.New("Usage: edit [-e|-E]") + } + for _, opt := range opts { + switch opt.Option { + case 'e': + editHeaders = true + case 'E': + editHeaders = false + } + } + + err = composer.ShowTerminal(editHeaders) if err != nil { return err } |