aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2023-11-20 09:11:29 +0100
committerRobin Jarry <robin@jarry.cc>2023-11-23 00:14:29 +0100
commit4120de14a8b184c18f7922553d5841d433379f41 (patch)
treec57e85ced1dccfd2ecc47eac4047f2482e7909c9 /commands/msg
parentfed43457403fb09102968f13fe8b1ce994517c74 (diff)
downloadaerc-4120de14a8b184c18f7922553d5841d433379f41.tar.gz
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 <account>`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/reply.go21
1 files changed, 18 insertions, 3 deletions
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()