From 4c514ce4d15fd14cad528cf426bc3f853efe7f64 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Wed, 5 Jul 2023 23:10:39 +0200 Subject: 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 Tested-by: Bence Ferdinandy Tested-by: Koni Marti --- commands/compose/edit.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'commands/compose/edit.go') 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 } -- cgit