diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-15 00:36:56 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-16 16:12:05 +0100 |
commit | f96172f5064b7245dfdb766163ceee856e2ee51b (patch) | |
tree | 3eed51fd23255ca310ecfb3d9e988d914fe5b2b0 /config/config.go | |
parent | 17bb9387c4a3ecab17ace3dc78694c2236a1024f (diff) | |
download | aerc-f96172f5064b7245dfdb766163ceee856e2ee51b.tar.gz |
config: move [compose] parsing in separate file
The config.go file is getting too big. Move the aerc.conf [compose]
section parsing logic into a dedicated compose.go file.
No functional change.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config/config.go')
-rw-r--r-- | config/config.go | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/config/config.go b/config/config.go index dc749cf4..95bf8d43 100644 --- a/config/config.go +++ b/config/config.go @@ -2,11 +2,9 @@ package config import ( "errors" - "fmt" "log" "os" "path" - "regexp" "strings" "unicode" @@ -18,14 +16,6 @@ import ( "git.sr.ht/~rjarry/aerc/logging" ) -type ComposeConfig struct { - Editor string `ini:"editor"` - HeaderLayout [][]string `ini:"-"` - AddressBookCmd string `ini:"address-book-cmd"` - ReplyToSelf bool `ini:"reply-to-self"` - NoAttachmentWarning *regexp.Regexp `ini:"-"` -} - type ViewerConfig struct { Pager string Alternatives []string @@ -171,28 +161,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { return err } } - if compose, err := file.GetSection("compose"); err == nil { - if err := compose.MapTo(&config.Compose); err != nil { - return err - } - for key, val := range compose.KeysHash() { - if key == "header-layout" { - config.Compose.HeaderLayout = parseLayout(val) - } - - if key == "no-attachment-warning" && len(val) > 0 { - re, err := regexp.Compile("(?im)" + val) - if err != nil { - return fmt.Errorf( - "Invalid no-attachment-warning '%s': %w", - val, err, - ) - } - - config.Compose.NoAttachmentWarning = re - } - } - } if triggers, err := file.GetSection("triggers"); err == nil { if err := triggers.MapTo(&config.Triggers); err != nil { @@ -255,14 +223,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { DisplayMode: "", }, - Compose: ComposeConfig{ - HeaderLayout: [][]string{ - {"To", "From"}, - {"Subject"}, - }, - ReplyToSelf: true, - }, - + Compose: defaultComposeConfig(), Templates: defaultTemplatesConfig(), Openers: make(map[string][]string), } @@ -270,6 +231,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if err := config.parseFilters(file); err != nil { return nil, err } + if err := config.parseCompose(file); err != nil { + return nil, err + } if err = config.LoadConfig(file); err != nil { return nil, err } @@ -282,7 +246,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline) logging.Debugf("aerc.conf: [viewer] %#v", config.Viewer) - logging.Debugf("aerc.conf: [compose] %#v", config.Compose) logging.Debugf("aerc.conf: [openers] %#v", config.Openers) logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers) |