summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2022-11-24 15:11:26 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:59:44 +0100
commitc2c5cbd4c0d6254ce4553e56f1b2b010858eb869 (patch)
treeaada282b14cb87d0ddf1b8c92f92f31e65559ac9
parent17718981c5d1db0775407d45f83dcd026758ab47 (diff)
downloadaerc-c2c5cbd4c0d6254ce4553e56f1b2b010858eb869.tar.gz
aerc-c2c5cbd4c0d6254ce4553e56f1b2b010858eb869.zip
view: add close-on-reply option
Opening an email to view and then to reply will have two tabs open, and after a reply the view tab needs to be closed manually. Allow the user to set a close-on-reply option that will close the viewer tab when replying and reopen the viewer tab in case the reply is not sent. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/msg/reply.go12
-rw-r--r--config/viewer.go2
-rw-r--r--doc/aerc-config.5.scd5
3 files changed, 18 insertions, 1 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 066eaca3..12eba928 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -10,6 +10,7 @@ import (
"git.sr.ht/~sircmpwn/getopt"
+ "git.sr.ht/~rjarry/aerc/commands/account"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/crypto"
"git.sr.ht/~rjarry/aerc/lib/format"
@@ -176,6 +177,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
RFC822Headers: msg.RFC822Headers,
}
+ mv, _ := aerc.SelectedTabContent().(*widgets.MessageViewer)
addTab := func() error {
composer, err := widgets.NewComposer(aerc, acct, aerc.Config(),
acct.AccountConfig(), acct.Worker(), template, h, original)
@@ -183,6 +185,10 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
aerc.PushError("Error: " + err.Error())
return err
}
+ if (mv != nil) && aerc.Config().Viewer.CloseOnReply {
+ mv.Close()
+ aerc.RemoveTab(mv)
+ }
if args[0] == "reply" {
composer.FocusTerminal()
@@ -199,8 +205,12 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
})
composer.OnClose(func(c *widgets.Composer) {
- if c.Sent() {
+ switch {
+ case c.Sent():
store.Answered([]uint32{msg.Uid}, true, nil)
+ case mv != nil && aerc.Config().Viewer.CloseOnReply:
+ //nolint:errcheck // who cares?
+ account.ViewMessage{}.Execute(aerc, []string{"-p"})
}
})
diff --git a/config/viewer.go b/config/viewer.go
index c00e62f4..3f7c6934 100644
--- a/config/viewer.go
+++ b/config/viewer.go
@@ -15,6 +15,7 @@ type ViewerConfig struct {
ParseHttpLinks bool `ini:"parse-http-links"`
HeaderLayout [][]string `ini:"-"`
KeyPassthrough bool `ini:"-"`
+ CloseOnReply bool `ini:"close-on-reply"`
}
func defaultViewerConfig() ViewerConfig {
@@ -29,6 +30,7 @@ func defaultViewerConfig() ViewerConfig {
{"Subject"},
},
ParseHttpLinks: true,
+ CloseOnReply: false,
}
}
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 40825864..ac9a3a73 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -500,6 +500,11 @@ These options are configured in the *[viewer]* section of _aerc.conf_.
Default: _true_
+*close-on-reply*
+ Close the view tab when replying. If the reply is not sent, reopen the view tab.
+
+ Default: _false_
+
# COMPOSE
These options are configured in the *[compose]* section of _aerc.conf_.