aboutsummaryrefslogtreecommitdiffstats
path: root/commands/compose
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-12-12 15:03:30 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-14 11:22:58 +0100
commitc05c2ffe0424b048b10e7dd1aca59ae9cf631f12 (patch)
tree13a3a84eb74fdea77996161f01bec5596f67f39f /commands/compose
parent9d0297e9d913a92b2d7ae02692e83f0f4093a766 (diff)
downloadaerc-c05c2ffe0424b048b10e7dd1aca59ae9cf631f12.tar.gz
config: make various sections accessible via global vars
There is only one instance of AercConfig which is associated to the Aerc widget. Everywhere we need to access configuration options, we need somehow to get a reference either to the Aerc widget or to a pointer to the AercConfig instance. This makes the code cluttered. Remove the AercConfig structure and every place where it is referenced. Instead, declare global variables for every configuration section and access them directly from the `config` module. Since bindings and ui sections can be "contextual" (i.e. per account, per folder or per subject), leave most local references intact. Replacing them with config.{Ui,Binds}.For{Account,Folder,Subject} would make this patch even more unreadable. This is something that may be addressed in the future. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'commands/compose')
-rw-r--r--commands/compose/attach.go3
-rw-r--r--commands/compose/multipart.go5
-rw-r--r--commands/compose/send.go2
3 files changed, 6 insertions, 4 deletions
diff --git a/commands/compose/attach.go b/commands/compose/attach.go
index 62ae0291..7e50ea85 100644
--- a/commands/compose/attach.go
+++ b/commands/compose/attach.go
@@ -11,6 +11,7 @@ import (
"strings"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/widgets"
@@ -85,7 +86,7 @@ func (a Attach) addPath(aerc *widgets.Aerc, path string) error {
}
func (a Attach) openMenu(aerc *widgets.Aerc, args []string) error {
- filePickerCmd := aerc.Config().Compose.FilePickerCmd
+ filePickerCmd := config.Compose.FilePickerCmd
if filePickerCmd == "" {
return fmt.Errorf("no file-picker-cmd defined")
}
diff --git a/commands/compose/multipart.go b/commands/compose/multipart.go
index 5a6dd770..32801965 100644
--- a/commands/compose/multipart.go
+++ b/commands/compose/multipart.go
@@ -5,6 +5,7 @@ import (
"fmt"
"git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
)
@@ -22,7 +23,7 @@ func (Multipart) Aliases() []string {
func (Multipart) Complete(aerc *widgets.Aerc, args []string) []string {
var completions []string
completions = append(completions, "-d")
- for mime := range aerc.Config().Converters {
+ for mime := range config.Converters {
completions = append(completions, mime)
}
return commands.CompletionFromList(aerc, completions, args)
@@ -53,7 +54,7 @@ func (a Multipart) Execute(aerc *widgets.Aerc, args []string) error {
if remove {
return composer.RemovePart(mime)
} else {
- _, found := aerc.Config().Converters[mime]
+ _, found := config.Converters[mime]
if !found {
return fmt.Errorf("no command defined for MIME type: %s", mime)
}
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 6d9bfe25..7306bef8 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -108,7 +108,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
msg = "Failed to check for a forgotten attachment."
}
- prompt := widgets.NewPrompt(aerc.Config(),
+ prompt := widgets.NewPrompt(
msg+" Abort send? [Y/n] ",
func(text string) {
if text == "n" || text == "N" {