aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/config.go41
-rw-r--r--config/statusline.go33
2 files changed, 45 insertions, 29 deletions
diff --git a/config/config.go b/config/config.go
index 0c2bf5f3..ef824279 100644
--- a/config/config.go
+++ b/config/config.go
@@ -16,12 +16,6 @@ import (
"git.sr.ht/~rjarry/aerc/logging"
)
-type StatuslineConfig struct {
- RenderFormat string `ini:"render-format"`
- Separator string
- DisplayMode string `ini:"display-mode"`
-}
-
type TriggersConfig struct {
NewEmail string `ini:"new-email"`
ExecuteCommand func(command []string) error
@@ -133,11 +127,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
}
}
}
- if statusline, err := file.GetSection("statusline"); err == nil {
- if err := statusline.MapTo(&config.Statusline); err != nil {
- return err
- }
- }
if triggers, err := file.GetSection("triggers"); err == nil {
if err := triggers.MapTo(&config.Triggers); err != nil {
@@ -173,24 +162,16 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
}
file.NameMapper = mapName
config := &AercConfig{
- Bindings: defaultBindsConfig(),
-
+ Bindings: defaultBindsConfig(),
ContextualBinds: []BindingConfigContext{},
-
- General: defaultGeneralConfig(),
- Ui: defaultUiConfig(),
- ContextualUis: []UIConfigContext{},
- Viewer: defaultViewerConfig(),
-
- Statusline: StatuslineConfig{
- RenderFormat: "[%a] %S %>%T",
- Separator: " | ",
- DisplayMode: "",
- },
-
- Compose: defaultComposeConfig(),
- Templates: defaultTemplatesConfig(),
- Openers: make(map[string][]string),
+ General: defaultGeneralConfig(),
+ Ui: defaultUiConfig(),
+ ContextualUis: []UIConfigContext{},
+ Viewer: defaultViewerConfig(),
+ Statusline: defaultStatuslineConfig(),
+ Compose: defaultComposeConfig(),
+ Templates: defaultTemplatesConfig(),
+ Openers: make(map[string][]string),
}
if err := config.parseFilters(file); err != nil {
@@ -202,6 +183,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if err := config.parseViewer(file); err != nil {
return nil, err
}
+ if err := config.parseStatusline(file); err != nil {
+ return nil, err
+ }
if err = config.LoadConfig(file); err != nil {
return nil, err
}
@@ -212,7 +196,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
return nil, err
}
- logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline)
logging.Debugf("aerc.conf: [openers] %#v", config.Openers)
logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers)
diff --git a/config/statusline.go b/config/statusline.go
new file mode 100644
index 00000000..a289c84d
--- /dev/null
+++ b/config/statusline.go
@@ -0,0 +1,33 @@
+package config
+
+import (
+ "git.sr.ht/~rjarry/aerc/logging"
+ "github.com/go-ini/ini"
+)
+
+type StatuslineConfig struct {
+ RenderFormat string `ini:"render-format"`
+ Separator string
+ DisplayMode string `ini:"display-mode"`
+}
+
+func defaultStatuslineConfig() StatuslineConfig {
+ return StatuslineConfig{
+ RenderFormat: "[%a] %S %>%T",
+ Separator: " | ",
+ DisplayMode: "",
+ }
+}
+
+func (config *AercConfig) parseStatusline(file *ini.File) error {
+ statusline, err := file.GetSection("statusline")
+ if err != nil {
+ goto out
+ }
+ if err := statusline.MapTo(&config.Statusline); err != nil {
+ return err
+ }
+out:
+ logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline)
+ return nil
+}