aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/accounts.go12
-rw-r--r--config/binds.go62
-rw-r--r--config/compose.go16
-rw-r--r--config/config.go82
-rw-r--r--config/converters.go8
-rw-r--r--config/filters.go8
-rw-r--r--config/general.go24
-rw-r--r--config/openers.go8
-rw-r--r--config/statusline.go12
-rw-r--r--config/templates.go20
-rw-r--r--config/triggers.go20
-rw-r--r--config/ui.go32
-rw-r--r--config/viewer.go16
13 files changed, 158 insertions, 162 deletions
diff --git a/config/accounts.go b/config/accounts.go
index 61f0e282..54c6556f 100644
--- a/config/accounts.go
+++ b/config/accounts.go
@@ -104,9 +104,11 @@ type AccountConfig struct {
TrustedAuthRes []string `ini:"trusted-authres" delim:","`
}
-func (config *AercConfig) parseAccounts(root string, accts []string) error {
+var Accounts []*AccountConfig
+
+func parseAccounts(root string, accts []string) error {
filename := path.Join(root, "accounts.conf")
- if !config.General.UnsafeAccountsConf {
+ if !General.UnsafeAccountsConf {
if err := checkConfigPerms(filename); err != nil {
return err
}
@@ -217,15 +219,15 @@ func (config *AercConfig) parseAccounts(root string, accts []string) error {
}
log.Debugf("accounts.conf: [%s] from = %s", account.Name, account.From)
- config.Accounts = append(config.Accounts, account)
+ Accounts = append(Accounts, &account)
}
if len(accts) > 0 {
// Sort accounts struct to match the specified order, if we
// have one
- if len(config.Accounts) != len(accts) {
+ if len(Accounts) != len(accts) {
return errors.New("account(s) not found")
}
- sort.Slice(config.Accounts, func(i, j int) bool {
+ sort.Slice(Accounts, func(i, j int) bool {
return strings.ToLower(accts[i]) < strings.ToLower(accts[j])
})
}
diff --git a/config/binds.go b/config/binds.go
index abaff78c..60e3a854 100644
--- a/config/binds.go
+++ b/config/binds.go
@@ -77,14 +77,28 @@ const (
type BindingSearchResult int
-func (config *AercConfig) parseBinds(root string) error {
+func defaultBindsConfig() *BindingConfig {
// These bindings are not configurable
- config.Bindings.AccountWizard.ExKey = KeyStroke{
- Key: tcell.KeyCtrlE,
- }
+ wizard := NewKeyBindings()
+ wizard.ExKey = KeyStroke{Key: tcell.KeyCtrlE}
quit, _ := ParseBinding("<C-q>", ":quit<Enter>")
- config.Bindings.AccountWizard.Add(quit)
+ wizard.Add(quit)
+ return &BindingConfig{
+ Global: NewKeyBindings(),
+ AccountWizard: wizard,
+ Compose: NewKeyBindings(),
+ ComposeEditor: NewKeyBindings(),
+ ComposeReview: NewKeyBindings(),
+ MessageList: NewKeyBindings(),
+ MessageView: NewKeyBindings(),
+ MessageViewPassthrough: NewKeyBindings(),
+ Terminal: NewKeyBindings(),
+ }
+}
+
+var Binds = defaultBindsConfig()
+func parseBinds(root string) error {
filename := path.Join(root, "binds.conf")
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
fmt.Printf("%s not found, installing the system default", filename)
@@ -99,14 +113,14 @@ func (config *AercConfig) parseBinds(root string) error {
}
baseGroups := map[string]**KeyBindings{
- "default": &config.Bindings.Global,
- "compose": &config.Bindings.Compose,
- "messages": &config.Bindings.MessageList,
- "terminal": &config.Bindings.Terminal,
- "view": &config.Bindings.MessageView,
- "view::passthrough": &config.Bindings.MessageViewPassthrough,
- "compose::editor": &config.Bindings.ComposeEditor,
- "compose::review": &config.Bindings.ComposeReview,
+ "default": &Binds.Global,
+ "compose": &Binds.Compose,
+ "messages": &Binds.MessageList,
+ "terminal": &Binds.Terminal,
+ "view": &Binds.MessageView,
+ "view::passthrough": &Binds.MessageViewPassthrough,
+ "compose::editor": &Binds.ComposeEditor,
+ "compose::review": &Binds.ComposeReview,
}
// Base Bindings
@@ -123,14 +137,14 @@ func (config *AercConfig) parseBinds(root string) error {
}
if baseOnly {
- err = config.LoadBinds(binds, baseSectionName, group)
+ err = LoadBinds(binds, baseSectionName, group)
if err != nil {
return err
}
}
}
- log.Debugf("binds.conf: %#v", config.Bindings)
+ log.Debugf("binds.conf: %#v", Binds)
return nil
}
@@ -167,7 +181,7 @@ func LoadBindingSection(sec *ini.Section) (*KeyBindings, error) {
return bindings, nil
}
-func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error {
+func LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error {
if sec, err := binds.GetSection(baseName); err == nil {
binds, err := LoadBindingSection(sec)
if err != nil {
@@ -221,7 +235,7 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
case "account":
acctName := sectionName[index+1:]
valid := false
- for _, acctConf := range config.Accounts {
+ for _, acctConf := range Accounts {
matches := contextualBind.Regex.FindString(acctConf.Name)
if matches != "" {
valid = true
@@ -246,20 +260,6 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
return nil
}
-func defaultBindsConfig() BindingConfig {
- return BindingConfig{
- Global: NewKeyBindings(),
- AccountWizard: NewKeyBindings(),
- Compose: NewKeyBindings(),
- ComposeEditor: NewKeyBindings(),
- ComposeReview: NewKeyBindings(),
- MessageList: NewKeyBindings(),
- MessageView: NewKeyBindings(),
- MessageViewPassthrough: NewKeyBindings(),
- Terminal: NewKeyBindings(),
- }
-}
-
func NewKeyBindings() *KeyBindings {
return &KeyBindings{
ExKey: KeyStroke{tcell.ModNone, tcell.KeyRune, ':'},
diff --git a/config/compose.go b/config/compose.go
index cf9c9b58..80d93204 100644
--- a/config/compose.go
+++ b/config/compose.go
@@ -17,8 +17,8 @@ type ComposeConfig struct {
FilePickerCmd string `ini:"file-picker-cmd"`
}
-func defaultComposeConfig() ComposeConfig {
- return ComposeConfig{
+func defaultComposeConfig() *ComposeConfig {
+ return &ComposeConfig{
HeaderLayout: [][]string{
{"To", "From"},
{"Subject"},
@@ -27,18 +27,20 @@ func defaultComposeConfig() ComposeConfig {
}
}
-func (config *AercConfig) parseCompose(file *ini.File) error {
+var Compose = defaultComposeConfig()
+
+func parseCompose(file *ini.File) error {
compose, err := file.GetSection("compose")
if err != nil {
goto end
}
- if err := compose.MapTo(&config.Compose); err != nil {
+ if err := compose.MapTo(&Compose); err != nil {
return err
}
for key, val := range compose.KeysHash() {
if key == "header-layout" {
- config.Compose.HeaderLayout = parseLayout(val)
+ Compose.HeaderLayout = parseLayout(val)
}
if key == "no-attachment-warning" && len(val) > 0 {
@@ -50,11 +52,11 @@ func (config *AercConfig) parseCompose(file *ini.File) error {
)
}
- config.Compose.NoAttachmentWarning = re
+ Compose.NoAttachmentWarning = re
}
}
end:
- log.Debugf("aerc.conf: [compose] %#v", config.Compose)
+ log.Debugf("aerc.conf: [compose] %#v", Compose)
return nil
}
diff --git a/config/config.go b/config/config.go
index 90951985..09fb5efc 100644
--- a/config/config.go
+++ b/config/config.go
@@ -14,21 +14,6 @@ import (
"github.com/mitchellh/go-homedir"
)
-type AercConfig struct {
- Bindings BindingConfig
- Compose ComposeConfig
- Converters map[string]string
- Accounts []AccountConfig `ini:"-"`
- Filters []FilterConfig `ini:"-"`
- Viewer ViewerConfig `ini:"-"`
- Statusline StatuslineConfig `ini:"-"`
- Triggers TriggersConfig `ini:"-"`
- Ui UIConfig
- General GeneralConfig
- Templates TemplateConfig
- Openers map[string][]string
-}
-
// Input: TimestampFormat
// Output: timestamp-format
func mapName(raw string) string {
@@ -108,7 +93,7 @@ func installTemplate(root, name string) error {
return nil
}
-func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
+func LoadConfigFromFile(root *string, accts []string) error {
if root == nil {
_root := path.Join(xdg.ConfigHome(), "aerc")
root = &_root
@@ -119,7 +104,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
fmt.Printf("%s not found, installing the system default", filename)
if err := installTemplate(*root, "aerc.conf"); err != nil {
- return nil, err
+ return err
}
}
@@ -127,59 +112,48 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
KeyValueDelimiters: "=",
}, filename)
if err != nil {
- return nil, err
+ return err
}
file.NameMapper = mapName
- config := &AercConfig{
- Bindings: defaultBindsConfig(),
- General: defaultGeneralConfig(),
- Ui: defaultUiConfig(),
- Viewer: defaultViewerConfig(),
- Statusline: defaultStatuslineConfig(),
- Compose: defaultComposeConfig(),
- Converters: make(map[string]string),
- Templates: defaultTemplatesConfig(),
- Openers: make(map[string][]string),
- }
- if err := config.parseGeneral(file); err != nil {
- return nil, err
+ if err := parseGeneral(file); err != nil {
+ return err
}
- if err := config.parseFilters(file); err != nil {
- return nil, err
+ if err := parseFilters(file); err != nil {
+ return err
}
- if err := config.parseCompose(file); err != nil {
- return nil, err
+ if err := parseCompose(file); err != nil {
+ return err
}
- if err := config.parseConverters(file); err != nil {
- return nil, err
+ if err := parseConverters(file); err != nil {
+ return err
}
- if err := config.parseViewer(file); err != nil {
- return nil, err
+ if err := parseViewer(file); err != nil {
+ return err
}
- if err := config.parseStatusline(file); err != nil {
- return nil, err
+ if err := parseStatusline(file); err != nil {
+ return err
}
- if err := config.parseOpeners(file); err != nil {
- return nil, err
+ if err := parseOpeners(file); err != nil {
+ return err
}
- if err := config.parseTriggers(file); err != nil {
- return nil, err
+ if err := parseTriggers(file); err != nil {
+ return err
}
- if err := config.parseUi(file); err != nil {
- return nil, err
+ if err := parseUi(file); err != nil {
+ return err
}
- if err := config.parseTemplates(file); err != nil {
- return nil, err
+ if err := parseTemplates(file); err != nil {
+ return err
}
- if err := config.parseAccounts(*root, accts); err != nil {
- return nil, err
+ if err := parseAccounts(*root, accts); err != nil {
+ return err
}
- if err := config.parseBinds(*root); err != nil {
- return nil, err
+ if err := parseBinds(*root); err != nil {
+ return err
}
- return config, nil
+ return nil
}
func parseLayout(layout string) [][]string {
diff --git a/config/converters.go b/config/converters.go
index 8c6b88df..72c1cbd4 100644
--- a/config/converters.go
+++ b/config/converters.go
@@ -8,7 +8,9 @@ import (
"github.com/go-ini/ini"
)
-func (config *AercConfig) parseConverters(file *ini.File) error {
+var Converters = make(map[string]string)
+
+func parseConverters(file *ini.File) error {
converters, err := file.GetSection("multipart-converters")
if err != nil {
goto out
@@ -25,10 +27,10 @@ func (config *AercConfig) parseConverters(file *ini.File) error {
"multipart-converters: %q: only text/* MIME types are supported",
mimeType)
}
- config.Converters[mimeType] = command
+ Converters[mimeType] = command
}
out:
- log.Debugf("aerc.conf: [multipart-converters] %#v", config.Converters)
+ log.Debugf("aerc.conf: [multipart-converters] %#v", Converters)
return nil
}
diff --git a/config/filters.go b/config/filters.go
index 2b5a0c84..0b7a1cb2 100644
--- a/config/filters.go
+++ b/config/filters.go
@@ -23,7 +23,9 @@ type FilterConfig struct {
Regex *regexp.Regexp
}
-func (config *AercConfig) parseFilters(file *ini.File) error {
+var Filters []*FilterConfig
+
+func parseFilters(file *ini.File) error {
filters, err := file.GetSection("filters")
if err != nil {
goto end
@@ -58,10 +60,10 @@ func (config *AercConfig) parseFilters(file *ini.File) error {
default:
filter.Type = FILTER_MIMETYPE
}
- config.Filters = append(config.Filters, filter)
+ Filters = append(Filters, &filter)
}
end:
- log.Debugf("aerc.conf: [filters] %#v", config.Filters)
+ log.Debugf("aerc.conf: [filters] %#v", Filters)
return nil
}
diff --git a/config/general.go b/config/general.go
index 2c09a14e..2921fdf5 100644
--- a/config/general.go
+++ b/config/general.go
@@ -18,15 +18,17 @@ type GeneralConfig struct {
LogLevel log.LogLevel `ini:"-"`
}
-func defaultGeneralConfig() GeneralConfig {
- return GeneralConfig{
+func defaultGeneralConfig() *GeneralConfig {
+ return &GeneralConfig{
PgpProvider: "auto",
UnsafeAccountsConf: false,
LogLevel: log.INFO,
}
}
-func (config *AercConfig) parseGeneral(file *ini.File) error {
+var General = defaultGeneralConfig()
+
+func parseGeneral(file *ini.File) error {
var level *ini.Key
var logFile *os.File
@@ -34,7 +36,7 @@ func (config *AercConfig) parseGeneral(file *ini.File) error {
if err != nil {
goto end
}
- if err := gen.MapTo(&config.General); err != nil {
+ if err := gen.MapTo(&General); err != nil {
return err
}
level, err = gen.GetKey("log-level")
@@ -43,18 +45,18 @@ func (config *AercConfig) parseGeneral(file *ini.File) error {
if err != nil {
return err
}
- config.General.LogLevel = l
+ General.LogLevel = l
}
- if err := config.General.validatePgpProvider(); err != nil {
+ if err := General.validatePgpProvider(); err != nil {
return err
}
end:
if !isatty.IsTerminal(os.Stdout.Fd()) {
logFile = os.Stdout
// redirected to file, force TRACE level
- config.General.LogLevel = log.TRACE
- } else if config.General.LogFile != "" {
- path, err := homedir.Expand(config.General.LogFile)
+ General.LogLevel = log.TRACE
+ } else if General.LogFile != "" {
+ path, err := homedir.Expand(General.LogFile)
if err != nil {
return fmt.Errorf("log-file: %w", err)
}
@@ -64,8 +66,8 @@ end:
return fmt.Errorf("log-file: %w", err)
}
}
- log.Init(logFile, config.General.LogLevel)
- log.Debugf("aerc.conf: [general] %#v", config.General)
+ log.Init(logFile, General.LogLevel)
+ log.Debugf("aerc.conf: [general] %#v", General)
return nil
}
diff --git a/config/openers.go b/config/openers.go
index c62ec974..181536f5 100644
--- a/config/openers.go
+++ b/config/openers.go
@@ -8,7 +8,9 @@ import (
"github.com/google/shlex"
)
-func (config *AercConfig) parseOpeners(file *ini.File) error {
+var Openers = make(map[string][]string)
+
+func parseOpeners(file *ini.File) error {
openers, err := file.GetSection("openers")
if err != nil {
goto out
@@ -19,11 +21,11 @@ func (config *AercConfig) parseOpeners(file *ini.File) error {
if args, err := shlex.Split(command); err != nil {
return err
} else {
- config.Openers[mimeType] = args
+ Openers[mimeType] = args
}
}
out:
- log.Debugf("aerc.conf: [openers] %#v", config.Openers)
+ log.Debugf("aerc.conf: [openers] %#v", Openers)
return nil
}
diff --git a/config/statusline.go b/config/statusline.go
index 1e7d723e..483241c0 100644
--- a/config/statusline.go
+++ b/config/statusline.go
@@ -11,23 +11,25 @@ type StatuslineConfig struct {
DisplayMode string `ini:"display-mode"`
}
-func defaultStatuslineConfig() StatuslineConfig {
- return StatuslineConfig{
+func defaultStatuslineConfig() *StatuslineConfig {
+ return &StatuslineConfig{
RenderFormat: "[%a] %S %>%T",
Separator: " | ",
DisplayMode: "",
}
}
-func (config *AercConfig) parseStatusline(file *ini.File) error {
+var Statusline = defaultStatuslineConfig()
+
+func parseStatusline(file *ini.File) error {
statusline, err := file.GetSection("statusline")
if err != nil {
goto out
}
- if err := statusline.MapTo(&config.Statusline); err != nil {
+ if err := statusline.MapTo(&Statusline); err != nil {
return err
}
out:
- log.Debugf("aerc.conf: [statusline] %#v", config.Statusline)
+ log.Debugf("aerc.conf: [statusline] %#v", Statusline)
return nil
}
diff --git a/config/templates.go b/config/templates.go
index 32d838fc..5580c056 100644
--- a/config/templates.go
+++ b/config/templates.go
@@ -16,8 +16,8 @@ type TemplateConfig struct {
Forwards string `ini:"forwards"`
}
-func defaultTemplatesConfig() TemplateConfig {
- return TemplateConfig{
+func defaultTemplatesConfig() *TemplateConfig {
+ return &TemplateConfig{
TemplateDirs: []string{},
NewMessage: "new_message",
QuotedReply: "quoted_reply",
@@ -25,27 +25,29 @@ func defaultTemplatesConfig() TemplateConfig {
}
}
-func (config *AercConfig) parseTemplates(file *ini.File) error {
+var Templates = defaultTemplatesConfig()
+
+func parseTemplates(file *ini.File) error {
if templatesSec, err := file.GetSection("templates"); err == nil {
- if err := templatesSec.MapTo(&config.Templates); err != nil {
+ if err := templatesSec.MapTo(&Templates); err != nil {
return err
}
templateDirs := templatesSec.Key("template-dirs").String()
if templateDirs != "" {
- config.Templates.TemplateDirs = strings.Split(templateDirs, ":")
+ Templates.TemplateDirs = strings.Split(templateDirs, ":")
}
}
// append default paths to template-dirs
for _, dir := range SearchDirs {
- config.Templates.TemplateDirs = append(
- config.Templates.TemplateDirs, path.Join(dir, "templates"),
+ Templates.TemplateDirs = append(
+ Templates.TemplateDirs, path.Join(dir, "templates"),
)
}
// we want to fail during startup if the templates are not ok
// hence we do dummy executes here
- t := config.Templates
+ t := Templates
if err := templates.CheckTemplate(t.NewMessage, t.TemplateDirs); err != nil {
return err
}
@@ -56,7 +58,7 @@ func (config *AercConfig) parseTemplates(file *ini.File) error {
return err
}
- log.Debugf("aerc.conf: [templates] %#v", config.Templates)
+ log.Debugf("aerc.conf: [templates] %#v", Templates)
return nil
}
diff --git a/config/triggers.go b/config/triggers.go
index 2a357bc0..5f315362 100644
--- a/config/triggers.go
+++ b/config/triggers.go
@@ -17,16 +17,18 @@ type TriggersConfig struct {
ExecuteCommand func(command []string) error
}
-func (config *AercConfig) parseTriggers(file *ini.File) error {
+var Triggers = &TriggersConfig{}
+
+func parseTriggers(file *ini.File) error {
triggers, err := file.GetSection("triggers")
if err != nil {
goto out
}
- if err := triggers.MapTo(&config.Triggers); err != nil {
+ if err := triggers.MapTo(&Triggers); err != nil {
return err
}
out:
- log.Debugf("aerc.conf: [triggers] %#v", config.Triggers)
+ log.Debugf("aerc.conf: [triggers] %#v", Triggers)
return nil
}
@@ -52,16 +54,16 @@ func (trig *TriggersConfig) ExecTrigger(triggerCmd string,
return trig.ExecuteCommand(command)
}
-func (trig *TriggersConfig) ExecNewEmail(account *AccountConfig,
- conf *AercConfig, msg *models.MessageInfo,
+func (trig *TriggersConfig) ExecNewEmail(
+ account *AccountConfig, msg *models.MessageInfo,
) {
err := trig.ExecTrigger(trig.NewEmail,
func(part string) (string, error) {
formatstr, args, err := format.ParseMessageFormat(
- part, conf.Ui.TimestampFormat,
- conf.Ui.ThisDayTimeFormat,
- conf.Ui.ThisWeekTimeFormat,
- conf.Ui.ThisYearTimeFormat,
+ part, Ui.TimestampFormat,
+ Ui.ThisDayTimeFormat,
+ Ui.ThisWeekTimeFormat,
+ Ui.ThisYearTimeFormat,
format.Ctx{
FromAddress: account.From,
AccountName: account.Name,
diff --git a/config/ui.go b/config/ui.go
index 36b2a9a2..0fb6a248 100644
--- a/config/ui.go
+++ b/config/ui.go
@@ -82,7 +82,7 @@ const (
type UiConfigContext struct {
ContextType uiContextType
Regex *regexp.Regexp
- UiConfig UIConfig
+ UiConfig *UIConfig
}
type uiContextKey struct {
@@ -90,8 +90,8 @@ type uiContextKey struct {
value string
}
-func defaultUiConfig() UIConfig {
- return UIConfig{
+func defaultUiConfig() *UIConfig {
+ return &UIConfig{
AutoMarkRead: true,
IndexFormat: "%-20.20D %-17.17n %Z %s",
TimestampFormat: "2006-01-02 03:04 PM",
@@ -136,9 +136,11 @@ func defaultUiConfig() UIConfig {
}
}
-func (config *AercConfig) parseUi(file *ini.File) error {
+var Ui = defaultUiConfig()
+
+func parseUi(file *ini.File) error {
if ui, err := file.GetSection("ui"); err == nil {
- if err := config.Ui.parse(ui); err != nil {
+ if err := Ui.parse(ui); err != nil {
return err
}
}
@@ -157,7 +159,7 @@ func (config *AercConfig) parseUi(file *ini.File) error {
return err
}
contextualUi := UiConfigContext{
- UiConfig: uiSubConfig,
+ UiConfig: &uiSubConfig,
}
var index int
@@ -190,31 +192,31 @@ func (config *AercConfig) parseUi(file *ini.File) error {
default:
return fmt.Errorf("Unknown Contextual Ui Section: %s", sectionName)
}
- config.Ui.contextualUis = append(config.Ui.contextualUis, &contextualUi)
- config.Ui.contextualCounts[contextualUi.ContextType]++
+ Ui.contextualUis = append(Ui.contextualUis, &contextualUi)
+ Ui.contextualCounts[contextualUi.ContextType]++
}
// append default paths to styleset-dirs
for _, dir := range SearchDirs {
- config.Ui.StyleSetDirs = append(
- config.Ui.StyleSetDirs, path.Join(dir, "stylesets"),
+ Ui.StyleSetDirs = append(
+ Ui.StyleSetDirs, path.Join(dir, "stylesets"),
)
}
- if err := config.Ui.loadStyleSet(config.Ui.StyleSetDirs); err != nil {
+ if err := Ui.loadStyleSet(Ui.StyleSetDirs); err != nil {
return err
}
- for _, contextualUi := range config.Ui.contextualUis {
+ for _, contextualUi := range Ui.contextualUis {
if contextualUi.UiConfig.StyleSetName == "" &&
len(contextualUi.UiConfig.StyleSetDirs) == 0 {
continue // no need to do anything if nothing is overridden
}
// fill in the missing part from the base
if contextualUi.UiConfig.StyleSetName == "" {
- contextualUi.UiConfig.StyleSetName = config.Ui.StyleSetName
+ contextualUi.UiConfig.StyleSetName = Ui.StyleSetName
} else if len(contextualUi.UiConfig.StyleSetDirs) == 0 {
- contextualUi.UiConfig.StyleSetDirs = config.Ui.StyleSetDirs
+ contextualUi.UiConfig.StyleSetDirs = Ui.StyleSetDirs
}
// since at least one of them has changed, load the styleset
if err := contextualUi.UiConfig.loadStyleSet(
@@ -223,7 +225,7 @@ func (config *AercConfig) parseUi(file *ini.File) error {
}
}
- log.Debugf("aerc.conf: [ui] %#v", config.Ui)
+ log.Debugf("aerc.conf: [ui] %#v", Ui)
return nil
}
diff --git a/config/viewer.go b/config/viewer.go
index 3f7c6934..d5e32ac8 100644
--- a/config/viewer.go
+++ b/config/viewer.go
@@ -18,8 +18,8 @@ type ViewerConfig struct {
CloseOnReply bool `ini:"close-on-reply"`
}
-func defaultViewerConfig() ViewerConfig {
- return ViewerConfig{
+func defaultViewerConfig() *ViewerConfig {
+ return &ViewerConfig{
Pager: "less -R",
Alternatives: []string{"text/plain", "text/html"},
ShowHeaders: false,
@@ -34,23 +34,25 @@ func defaultViewerConfig() ViewerConfig {
}
}
-func (config *AercConfig) parseViewer(file *ini.File) error {
+var Viewer = defaultViewerConfig()
+
+func parseViewer(file *ini.File) error {
viewer, err := file.GetSection("viewer")
if err != nil {
goto out
}
- if err := viewer.MapTo(&config.Viewer); err != nil {
+ if err := viewer.MapTo(&Viewer); err != nil {
return err
}
for key, val := range viewer.KeysHash() {
switch key {
case "alternatives":
- config.Viewer.Alternatives = strings.Split(val, ",")
+ Viewer.Alternatives = strings.Split(val, ",")
case "header-layout":
- config.Viewer.HeaderLayout = parseLayout(val)
+ Viewer.HeaderLayout = parseLayout(val)
}
}
out:
- log.Debugf("aerc.conf: [viewer] %#v", config.Viewer)
+ log.Debugf("aerc.conf: [viewer] %#v", Viewer)
return nil
}