aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--commands/msg/reply.go21
-rw-r--r--doc/aerc.1.scd5
2 files changed, 22 insertions, 4 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()
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 6214d02e..28f223bb 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -299,7 +299,7 @@ message list, the message in the message viewer, etc).
_[PATCH X/Y]_), all marked messages will be sorted by subject to ensure
that the patches are applied in order.
-*:reply* [*-acq*] [*-T* _<template-file>_] [*-e*|*-E*]
+*:reply* [*-acq*] [*-T* _<template-file>_] [*-A* _<account>_] [*-e*|*-E*]
Opens the composer to reply to the selected message.
*-a*: Reply all
@@ -314,6 +314,9 @@ message list, the message in the message viewer, etc).
message body. If *-q* is specified, defaults to what is set as
*quoted-reply* in the *[templates]* section of _aerc.conf_.
+ *-A*_: _<account>_
+ Reply with the specified account instead of the current one.
+
*-e*: Forces *[compose].edit-headers* = _true_ for this message only.
*-E*: Forces *[compose].edit-headers* = _false_ for this message only.