From c6a8071f835b01e2385302ecb52e130754496c76 Mon Sep 17 00:00:00 2001 From: Johannes Thyssen Tishman Date: Fri, 12 Apr 2024 17:23:18 +0200 Subject: config: allow global options in accounts.conf Global options may be configured by placing them at the top of the accounts.conf file, before any account-specific sections. These can be overridden for an account by specifying them again in the account section. Changelog-added: Set global options in `accounts.conf` by placing them at the top of the file. Signed-off-by: Johannes Thyssen Tishman Tested-by: Bence Ferdinandy Acked-by: Robin Jarry --- config/accounts.go | 7 +++++++ doc/aerc-accounts.5.scd | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/accounts.go b/config/accounts.go index 6e0d6268..f0853ee6 100644 --- a/config/accounts.go +++ b/config/accounts.go @@ -132,14 +132,21 @@ func parseAccountsFromFile(root string, accts []string, filename string) error { } starttls_warned := false + var globals *ini.Section for _, _sec := range file.SectionStrings() { if _sec == "DEFAULT" { + globals = file.Section(_sec) continue } if len(accts) > 0 && !contains(accts, _sec) { continue } sec := file.Section(_sec) + for key, val := range globals.KeysHash() { + if !sec.HasKey(key) { + _, _ = sec.NewKey(key, val) + } + } account, err := ParseAccountConfig(_sec, sec) if err != nil { diff --git a/doc/aerc-accounts.5.scd b/doc/aerc-accounts.5.scd index d735e45c..14502409 100644 --- a/doc/aerc-accounts.5.scd +++ b/doc/aerc-accounts.5.scd @@ -17,9 +17,12 @@ be executed automatically on first startup. This file is written in the ini format where each *[section]* is the name of an account you want to configure, and the keys & values in that section specify -details of that account's configuration. In addition to the options documented -here, specific transports for incoming and outgoing emails may have additional -configuration parameters, documented on their respective man pages. +details of that account's configuration. Global options may be configured by +placing them at the top of the file, before any account-specific sections. These +can be overridden for an account by specifying them again in the account +section. In addition to the options documented here, specific transports for +incoming and outgoing emails may have additional configuration parameters, +documented on their respective man pages. # CONFIGURATION -- cgit v1.2.3-54-g00ecf