From 402612fd9788f071a5d7ae0045989977b98d896f Mon Sep 17 00:00:00 2001 From: Kalyan Sriram Date: Sat, 13 Nov 2021 08:10:09 +0000 Subject: 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. --- worker/notmuch/worker.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'worker/notmuch') diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index 63003292..09b5d509 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -35,6 +35,7 @@ type worker struct { query string currentQueryName string uidStore *uidstore.Store + queryMapOrder []string nameQueryMap map[string]string db *notmuch.DB setupErr error @@ -185,7 +186,7 @@ func (w *worker) handleConnect(msg *types.Connect) error { } func (w *worker) handleListDirectories(msg *types.ListDirectories) error { - for name := range w.nameQueryMap { + for _, name := range w.queryMapOrder { w.w.PostMessage(&types.Directory{ Message: types.RespondTo(msg), Dir: &models.Directory{ @@ -508,6 +509,7 @@ func (w *worker) loadQueryMap(acctConfig *config.AccountConfig) error { return fmt.Errorf("%v: invalid line %q, want name=query", file, line) } w.nameQueryMap[split[0]] = split[1] + w.queryMapOrder = append(w.queryMapOrder, split[0]) } return nil } -- cgit