~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Add a 'folders-exclude' option

Details
Message ID
<20200629084808.2381-1-araspik@protonmail.com>
DKIM signature
pass
Download raw message
Patch: +40 -14
Added a 'folders-exclude' option that allows removing selected folders
from the directory list sidebar. My motivating example was that removing
a single folder from the list using Golang regexes seemed pretty hard,
so this is a better way to do it. The excluded folders list is included
in the man page.

Thanks to Reto for reviewing and simplifying the commit.
---
 config/config.go      |  5 +++++
 doc/aerc-config.5.scd |  7 +++++++
 widgets/dirlist.go    | 42 ++++++++++++++++++++++++++++--------------
 3 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/config/config.go b/config/config.go
index 8ebd69d..ce59944 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,6 +76,7 @@ type AccountConfig struct {
	Source          string
	SourceCredCmd   string
	Folders         []string
	FoldersExclude	[]string
	Params          map[string]string
	Outgoing        string
	OutgoingCredCmd string
@@ -186,6 +187,10 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
				folders := strings.Split(val, ",")
				sort.Strings(folders)
				account.Folders = folders
			} else if key == "folders-exclude" {
				folders := strings.Split(val, ",")
				sort.Strings(folders)
				account.FoldersExclude = folders
			} else if key == "source-cred-cmd" {
				account.SourceCredCmd = val
			} else if key == "outgoing" {
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 2bd3076..af64ad6 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -376,6 +376,13 @@ Note that many of these configuration options are written for you, such as

	Default: all folders

*folders-exclude*
	Specifies the comma separated list of folders to exclude from the sidebar.
	Names prefixed with ~ are interpreted as regular expressions.
	Note that this overrides anything from *folders*.

	Default: no folders

*folders-sort*
	Specifies a comma separated list of folders to be shown at the top of the
	list in the provided order. Remaining folders will be sorted alphabetically.
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index f12631b..cb2f756 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -390,24 +390,38 @@ func (dirlist *DirectoryList) sortDirsByFoldersSortConfig() {
}

// filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the
// dirstore, based on the AccountConfig.Folders option
// dirstore, based on AccountConfig.Folders (inclusion) and
// AccountConfig.FoldersExclude (exclusion), in that order.
func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
	dirlist.dirs = dirlist.store.List()
	// config option defaults to show all if unset
	configFolders := dirlist.acctConf.Folders
	if len(configFolders) == 0 {
		return
	}
	var filtered []string
	for _, folder := range dirlist.dirs {
		for _, cfgfolder := range configFolders {
			if folderMatches(folder, cfgfolder) {
				filtered = append(filtered, folder)
				break
	filterDirs := func(orig, filters []string, exclude bool) []string {
		if len(filters) == 0 {
			return orig
		}
		var dest []string
		for _, folder := range orig {
			for _, f := range filters {
				matches := folderMatches(folder, f)
				if exclude {
					matches = !matches
				}
				if matches {
					dest = append(dest, folder)
					break
				}
			}
		}
		return dest
	}
	dirlist.dirs = filtered

	dirlist.dirs = dirlist.store.List()

	// 'folders' (if available) is used to make the initial list and
	// 'folders-exclude' removes from that list.
	configFolders := dirlist.acctConf.Folders
	dirlist.dirs = filterDirs(dirlist.dirs, configFolders, false)

	configFoldersExclude := dirlist.acctConf.FoldersExclude
	dirlist.dirs = filterDirs(dirlist.dirs, configFoldersExclude, true)
}

func (dirlist *DirectoryList) SelectedMsgStore() (*lib.MessageStore, bool) {
-- 
2.27.0
Details
Message ID
<11D3FC1D-684B-423B-B1CA-C58788E1F8C7@labrat.space>
In-Reply-To
<20200629084808.2381-1-araspik@protonmail.com> (view parent)
DKIM signature
pass
Download raw message
Nitpick, not sure how familiar you are with an email based workflow but the format of a patch is as follows:

>Added a 'folders-exclude' option that allows removing selected folders
>from the directory list sidebar. My motivating example was that
>removing
>a single folder from the list using Golang regexes seemed pretty hard,
>so this is a better way to do it. The excluded folders list is included
>in the man page.
>
>Thanks to Reto for reviewing and simplifying the commit.

Up until here is everything that ends up in the commit message, note the --- that mark the end 

>---

Below that, prior to the diffstat, you can add what's referred to as "just in time comments", so generally what changed between versions, salutations and everything else that shouldn't end up in the commit message. `git am` will simply strip this part out.

Thanking me, while certainly appreciated, probably isn't part of a good commit message ;)
In the future move it to this section please.

Greetings,
Reto
Review patch Export thread (mbox)