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. --- widgets/dirlist.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'widgets') diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 4db80a4..0345380 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -105,7 +105,9 @@ func (dirlist *DirectoryList) Select(name string) { if !hasSelected && dirlist.selected != "" { dirlist.dirs = append(dirlist.dirs, dirlist.selected) } - sort.Strings(dirlist.dirs) + if dirlist.acctConf.EnableFoldersSort { + sort.Strings(dirlist.dirs) + } dirlist.sortDirsByFoldersSortConfig() } dirlist.Invalidate() @@ -376,6 +378,10 @@ func folderMatches(folder string, pattern string) bool { // AccountConfig.FoldersSort option. Folders not included in the option // will be appended at the end in alphabetical order func (dirlist *DirectoryList) sortDirsByFoldersSortConfig() { + if !dirlist.acctConf.EnableFoldersSort { + return + } + sort.Slice(dirlist.dirs, func(i, j int) bool { foldersSort := dirlist.acctConf.FoldersSort iInFoldersSort := findString(foldersSort, dirlist.dirs[i]) -- cgit 1.4.1-2-gfad0