summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorKalyan Sriram <kalyan@coderkalyan.com>2021-11-13 08:10:09 +0000
committerRobin Jarry <robin@jarry.cc>2021-11-13 15:25:04 +0100
commit402612fd9788f071a5d7ae0045989977b98d896f (patch)
tree7d48f203a922cb6933146bda744f5dc3a9e90b07 /config
parent88d28908d2b2cd9d416bce76f384153ba1267cdb (diff)
downloadaerc-402612fd9788f071a5d7ae0045989977b98d896f.zip
notmuch: allow sort by file order
When using the notmuch backend, it often makes more sense to sort folders (actual virtual folders, or queries) by the order specified in the query-map file, rather than alphabetically. This patch introduces a configuration option (disabled by default) that allows this. Additionally, due to the notmuch backend previously using maps (which are order-undefined) to store the list of queries, default query selection on aerc startup fluctuated. This patch fixes that by using slices to store query order.
Diffstat (limited to 'config')
-rw-r--r--config/config.go49
1 files changed, 27 insertions, 22 deletions
diff --git a/config/config.go b/config/config.go
index 3fc38e3..9be55c6 100644
--- a/config/config.go
+++ b/config/config.go
@@ -10,6 +10,7 @@ import (
"path"
"regexp"
"sort"
+ "strconv"
"strings"
"time"
"unicode"
@@ -74,23 +75,24 @@ const (
)
type AccountConfig struct {
- Archive string
- CopyTo string
- Default string
- Postpone string
- From string
- Aliases string
- Name string
- Source string
- SourceCredCmd string
- Folders []string
- FoldersExclude []string
- Params map[string]string
- Outgoing string
- OutgoingCredCmd string
- SignatureFile string
- SignatureCmd string
- FoldersSort []string `ini:"folders-sort" delim:","`
+ Archive string
+ CopyTo string
+ Default string
+ Postpone string
+ From string
+ Aliases string
+ Name string
+ Source string
+ SourceCredCmd string
+ Folders []string
+ FoldersExclude []string
+ Params map[string]string
+ Outgoing string
+ OutgoingCredCmd string
+ SignatureFile string
+ SignatureCmd string
+ EnableFoldersSort bool `ini:"enable-folders-sort"`
+ FoldersSort []string `ini:"folders-sort" delim:","`
}
type BindingConfig struct {
@@ -181,11 +183,12 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
}
sec := file.Section(_sec)
account := AccountConfig{
- Archive: "Archive",
- Default: "INBOX",
- Postpone: "Drafts",
- Name: _sec,
- Params: make(map[string]string),
+ Archive: "Archive",
+ Default: "INBOX",
+ Postpone: "Drafts",
+ Name: _sec,
+ Params: make(map[string]string),
+ EnableFoldersSort: true,
}
if err = sec.MapTo(&account); err != nil {
return nil, err
@@ -213,6 +216,8 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
account.CopyTo = val
} else if key == "archive" {
account.Archive = val
+ } else if key == "enable-folders-sort" {
+ account.EnableFoldersSort, _ = strconv.ParseBool(val)
} else if key != "name" {
account.Params[key] = val
}