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/msg/invite.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'commands/msg/invite.go') diff --git a/commands/msg/invite.go b/commands/msg/invite.go index 6273d520..309fe643 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -12,6 +12,7 @@ import ( "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~sircmpwn/getopt" "github.com/emersion/go-message/mail" ) @@ -48,6 +49,23 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { return fmt.Errorf("no invitation found (missing text/calendar)") } + editHeaders := config.Compose.EditHeaders + opts, optind, err := getopt.Getopts(args, "eE") + if err != nil { + return err + } + if len(args) != optind { + return errors.New("Usage: accept|accept-tentative|decline [-e|-E]") + } + for _, opt := range opts { + switch opt.Option { + case 'e': + editHeaders = true + case 'E': + editHeaders = false + } + } + subject := trimLocalizedRe(msg.Envelope.Subject, acct.AccountConfig().LocalizedRe) switch args[0] { case "accept": @@ -138,7 +156,8 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { addTab := func(cr *calendar.Reply) error { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", h, &original, cr.PlainText) + acct.AccountConfig(), acct.Worker(), editHeaders, + "", h, &original, cr.PlainText) if err != nil { aerc.PushError("Error: " + err.Error()) return err -- cgit