aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/reply.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-10 00:08:31 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-10 11:38:01 +0200
commitbc176bd61ba726351a489cabf4da16a47dc5ec3b (patch)
treebbf06f731592d072f3d6f76f1648d61989375f2e /commands/msg/reply.go
parent598e4a5803578ab3e291f232d6aad31b4efd8ea4 (diff)
downloadaerc-bc176bd61ba726351a489cabf4da16a47dc5ec3b.tar.gz
app: export global functions
The single Aerc object is passed around in almost all command functions. This hinders readability. Store the single Aerc instance as a global variable. Export public functions from the app package to access methods of that object. Remove all explicit references to *app.Aerc and replace them with calls to these functions. For references to private/unexported fields and functions from within the app package, directly access the global aerc object. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands/msg/reply.go')
-rw-r--r--commands/msg/reply.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 035e6aa3..b9ee050a 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -33,11 +33,11 @@ func (reply) Aliases() []string {
return []string{"reply"}
}
-func (reply) Complete(aerc *app.Aerc, args []string) []string {
+func (reply) Complete(args []string) []string {
return nil
}
-func (reply) Execute(aerc *app.Aerc, args []string) error {
+func (reply) Execute(args []string) error {
opts, optind, err := getopt.Getopts(args, "acqT:eE")
if err != nil {
return err
@@ -69,7 +69,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error {
}
}
- widget := aerc.SelectedTabContent().(app.ProvidesMessage)
+ widget := app.SelectedTabContent().(app.ProvidesMessage)
acct := widget.SelectedAccount()
if acct == nil {
@@ -169,7 +169,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error {
h.SetMsgIDList("in-reply-to", []string{msg.Envelope.MessageId})
err = setReferencesHeader(h, msg.RFC822Headers)
if err != nil {
- aerc.PushError(fmt.Sprintf("could not set references: %v", err))
+ app.PushError(fmt.Sprintf("could not set references: %v", err))
}
original := models.OriginalMail{
From: format.FormatAddresses(msg.Envelope.From),
@@ -177,38 +177,38 @@ func (reply) Execute(aerc *app.Aerc, args []string) error {
RFC822Headers: msg.RFC822Headers,
}
- mv, _ := aerc.SelectedTabContent().(*app.MessageViewer)
+ mv, _ := app.SelectedTabContent().(*app.MessageViewer)
addTab := func() error {
- composer, err := app.NewComposer(aerc, acct,
+ composer, err := app.NewComposer(acct,
acct.AccountConfig(), acct.Worker(), editHeaders,
template, h, &original, nil)
if err != nil {
- aerc.PushError("Error: " + err.Error())
+ app.PushError("Error: " + err.Error())
return err
}
if mv != nil && closeOnReply {
- aerc.RemoveTab(mv, true)
+ app.RemoveTab(mv, true)
}
if args[0] == "reply" {
composer.FocusTerminal()
}
- composer.Tab = aerc.NewTab(composer, subject)
+ composer.Tab = app.NewTab(composer, subject)
composer.OnClose(func(c *app.Composer) {
switch {
case c.Sent() && c.Archive() != "":
store.Answered([]uint32{msg.Uid}, true, nil)
- err := archive(aerc, []*models.MessageInfo{msg}, c.Archive())
+ err := archive([]*models.MessageInfo{msg}, c.Archive())
if err != nil {
- aerc.PushStatus("Archive failed", 10*time.Second)
+ app.PushStatus("Archive failed", 10*time.Second)
}
case c.Sent():
store.Answered([]uint32{msg.Uid}, true, nil)
case mv != nil && closeOnReply:
//nolint:errcheck // who cares?
- account.ViewMessage{}.Execute(aerc, []string{"-p"})
+ account.ViewMessage{}.Execute([]string{"-p"})
}
})
@@ -221,7 +221,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error {
}
if crypto.IsEncrypted(msg.BodyStructure) {
- provider := aerc.SelectedTabContent().(app.ProvidesMessage)
+ provider := app.SelectedTabContent().(app.ProvidesMessage)
mv, ok := provider.(*app.MessageViewer)
if !ok {
return fmt.Errorf("message is encrypted. can only quote reply while message is open")