From 4120de14a8b184c18f7922553d5841d433379f41 Mon Sep 17 00:00:00 2001 From: Bence Ferdinandy Date: Mon, 20 Nov 2023 09:11:29 +0100 Subject: reply: allow replying with another account When using edit-headers=true using :switch-account alone is not enough to properly switch account since you have to change the From header manually. Add the -A [account] option to reply in order to switch the account before opening the composer, to remove this friction when we already know we want to reply with a different account. Changelog-added: Reply with a different account than the current one with `:reply -A `. Signed-off-by: Bence Ferdinandy Acked-by: Robin Jarry --- commands/msg/reply.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'commands/msg/reply.go') diff --git a/commands/msg/reply.go b/commands/msg/reply.go index ebf20317..699c75fb 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -30,6 +30,7 @@ type reply struct { Template string `opt:"-T" complete:"CompleteTemplate"` Edit bool `opt:"-e"` NoEdit bool `opt:"-E"` + Account string `opt:"-A" complete:"CompleteAccount"` } func init() { @@ -44,14 +45,28 @@ func (*reply) CompleteTemplate(arg string) []string { return commands.GetTemplates(arg) } +func (*reply) CompleteAccount(arg string) []string { + return commands.FilterList(app.AccountNames(), arg, commands.QuoteSpace) +} + func (r reply) Execute(args []string) error { editHeaders := (config.Compose.EditHeaders || r.Edit) && !r.NoEdit widget := app.SelectedTabContent().(app.ProvidesMessage) - acct := widget.SelectedAccount() - if acct == nil { - return errors.New("No account selected") + var acct *app.AccountView + var err error + + if r.Account == "" { + acct = widget.SelectedAccount() + if acct == nil { + return errors.New("No account selected") + } + } else { + acct, err = app.Account(r.Account) + if err != nil { + return err + } } conf := acct.AccountConfig() -- cgit