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 --- commands/msg/move.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'commands/msg/move.go') diff --git a/commands/msg/move.go b/commands/msg/move.go index 15494364..6e77a88c 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -6,6 +6,7 @@ import ( "time" "git.sr.ht/~rjarry/aerc/commands" + "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/models" @@ -91,7 +92,7 @@ func handleDone( aerc.PushStatus(message, 10*time.Second) mv, isMsgView := h.msgProvider.(*widgets.MessageViewer) switch { - case isMsgView && !aerc.Config().Ui.NextMessageOnDelete: + case isMsgView && !config.Ui.NextMessageOnDelete: aerc.RemoveTab(h.msgProvider) case isMsgView: if next == nil { @@ -107,7 +108,7 @@ func handleDone( aerc.PushError(err.Error()) return } - nextMv := widgets.NewMessageViewer(acct, aerc.Config(), view) + nextMv := widgets.NewMessageViewer(acct, view) aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject) }) default: -- cgit