diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-10 00:08:31 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-10 11:38:01 +0200 |
commit | bc176bd61ba726351a489cabf4da16a47dc5ec3b (patch) | |
tree | bbf06f731592d072f3d6f76f1648d61989375f2e /app/aerc.go | |
parent | 598e4a5803578ab3e291f232d6aad31b4efd8ea4 (diff) | |
download | aerc-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 'app/aerc.go')
-rw-r--r-- | app/aerc.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/app/aerc.go b/app/aerc.go index a1995c2d..1170a6f2 100644 --- a/app/aerc.go +++ b/app/aerc.go @@ -87,10 +87,8 @@ func NewAerc( Crypto: crypto, } - statusline.SetAerc(aerc) - for _, acct := range config.Accounts { - view, err := NewAccountView(aerc, acct, aerc, deferLoop) + view, err := NewAccountView(acct, deferLoop) if err != nil { tabs.Add(errorScreen(err.Error()), acct.Name, nil) } else { @@ -100,7 +98,7 @@ func NewAerc( } if len(config.Accounts) == 0 { - wizard := NewAccountWizard(aerc) + wizard := NewAccountWizard() wizard.Focus(true) aerc.NewTab(wizard, "New account") } @@ -732,7 +730,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error { defer ui.Invalidate() - composer, err := NewComposer(aerc, acct, + composer, err := NewComposer(acct, acct.AccountConfig(), acct.Worker(), config.Compose.EditHeaders, template, h, nil, strings.NewReader(body)) @@ -775,7 +773,7 @@ func (aerc *Aerc) Mbox(source string) error { defer ui.Invalidate() - mboxView, err := NewAccountView(aerc, &acctConf, aerc, nil) + mboxView, err := NewAccountView(&acctConf, nil) if err != nil { aerc.NewTab(errorScreen(err.Error()), acctConf.Name) } else { @@ -886,9 +884,9 @@ func (aerc *Aerc) isExKey(event *tcell.EventKey, exKey config.KeyStroke) bool { return event.Modifiers() == exKey.Modifiers && event.Key() == exKey.Key } -// CmdFallbackSearch checks cmds for the first executable availabe in PATH. An error is +// cmdFallbackSearch checks cmds for the first executable availabe in PATH. An error is // returned if none are found -func (aerc *Aerc) CmdFallbackSearch(cmds []string) (string, error) { +func cmdFallbackSearch(cmds []string) (string, error) { var tried []string for _, cmd := range cmds { if cmd == "" { @@ -899,7 +897,7 @@ func (aerc *Aerc) CmdFallbackSearch(cmds []string) (string, error) { if err != nil { tried = append(tried, cmd) warn := fmt.Sprintf("cmd '%s' not found in PATH, using fallback", cmd) - aerc.PushWarning(warn) + PushWarning(warn) continue } return cmd, nil |