From c05c2ffe0424b048b10e7dd1aca59ae9cf631f12 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Mon, 12 Dec 2022 15:03:30 +0100 Subject: 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 Acked-by: Tim Culverhouse --- widgets/dirlist.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'widgets/dirlist.go') diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 0b41c024..4d27def2 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -48,7 +48,6 @@ type DirectoryLister interface { type DirectoryList struct { Scrollable - aercConf *config.AercConfig acctConf *config.AccountConfig store *lib.DirStore dirs []string @@ -60,13 +59,12 @@ type DirectoryList struct { skipSelectCancel context.CancelFunc } -func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig, +func NewDirectoryList(acctConf *config.AccountConfig, worker *types.Worker, ) DirectoryLister { ctx, cancel := context.WithCancel(context.Background()) dirlist := &DirectoryList{ - aercConf: conf, acctConf: acctConf, store: lib.NewDirStore(), worker: worker, @@ -88,7 +86,7 @@ func (dirlist *DirectoryList) UiConfig(dir string) *config.UIConfig { if dir == "" { dir = dirlist.Selected() } - return dirlist.aercConf.Ui.ForAccount(dirlist.acctConf.Name).ForFolder(dir) + return config.Ui.ForAccount(dirlist.acctConf.Name).ForFolder(dir) } func (dirlist *DirectoryList) List() []string { -- cgit