aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinwit <inwit@sindominio.net>2022-01-24 11:45:35 +0100
committerRobin Jarry <robin@jarry.cc>2022-01-24 11:48:51 +0100
commitd922d7325c7b50425b60f84fc7be1f8d32ec86fd (patch)
tree98370216200741cf657cade7b44dbf2fef295a93
parentcb3090956cfdc0ff4c2f06e4ef3c5eb73b73f9c0 (diff)
downloadaerc-d922d7325c7b50425b60f84fc7be1f8d32ec86fd.tar.gz
binds: Warning on unexistent account bindings
After commit 175d0ef ("binds: add account specific bindings"), when bindings are defined for an account not defined in accounts.conf, aerc quits with an error. After this commit, a warning is logged and aerc ignores those bindings. Signed-off-by: inwit <inwit@sindominio.net>
-rw-r--r--aerc.go2
-rw-r--r--config/config.go10
2 files changed, 7 insertions, 5 deletions
diff --git a/aerc.go b/aerc.go
index b3338ba1..9d83d2cf 100644
--- a/aerc.go
+++ b/aerc.go
@@ -158,7 +158,7 @@ func main() {
logger = log.New(logOut, "", log.LstdFlags)
logger.Println("Starting up aerc")
- conf, err := config.LoadConfigFromFile(nil, ShareDir)
+ conf, err := config.LoadConfigFromFile(nil, ShareDir, logger)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to load config: %v\n", err)
os.Exit(1)
diff --git a/config/config.go b/config/config.go
index 2e1d5893..374fd5c7 100644
--- a/config/config.go
+++ b/config/config.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/ioutil"
+ "log"
"net/url"
"os"
"os/exec"
@@ -502,7 +503,7 @@ func validateBorderChars(section *ini.Section, config *UIConfig) error {
return nil
}
-func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
+func LoadConfigFromFile(root *string, sharedir string, logger *log.Logger) (*AercConfig, error) {
if root == nil {
_root := path.Join(xdg.ConfigHome(), "aerc")
root = &_root
@@ -661,7 +662,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
}
if baseOnly {
- err = config.LoadBinds(binds, baseSectionName, group)
+ err = config.LoadBinds(binds, baseSectionName, group, logger)
if err != nil {
return nil, err
}
@@ -711,7 +712,7 @@ func LoadBindingSection(sec *ini.Section) (*KeyBindings, error) {
return bindings, nil
}
-func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error {
+func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings, logger *log.Logger) error {
if sec, err := binds.GetSection(baseName); err == nil {
binds, err := LoadBindingSection(sec)
@@ -766,7 +767,8 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
}
}
if !valid {
- return fmt.Errorf("Invalid Account Name: %s", acctName)
+ logger.Printf("Tried to define binds for unexistent account: %v\n", acctName)
+ continue
}
contextualBind.ContextType = BIND_CONTEXT_ACCOUNT
default: