diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | config/aerc.conf | 6 | ||||
-rw-r--r-- | config/config.go | 1 | ||||
-rw-r--r-- | doc/aerc-config.5.scd | 6 | ||||
-rw-r--r-- | widgets/dirtree.go | 9 |
5 files changed, 20 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3328c0f3..6dedbef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Run `check-mail-cmd` with `:check-mail`. - Display active key binds with `:help keys` (bound to `?` by default). - Multiple visual selections with `:mark -V`. +- Set default collapse depth of directory tree with `dirlist-collapse`. ### Changed diff --git a/config/aerc.conf b/config/aerc.conf index fc6479af..c60f4b03 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -103,6 +103,12 @@ dirlist-delay=200ms # Default: false dirlist-tree=false +# If dirlist-tree is enabled, set level at which folders are collapsed by +# default. Set to 0 to disable. +# +# Default: 0 +dirlist-collapse=0 + # List of space-separated criteria to sort the messages by, see *sort* # command in *aerc*(1) for reference. Prefixing a criterion with "-r " # reverses that criterion. diff --git a/config/config.go b/config/config.go index c6fe70ee..f0a74744 100644 --- a/config/config.go +++ b/config/config.go @@ -61,6 +61,7 @@ type UIConfig struct { DirListFormat string `ini:"dirlist-format"` DirListDelay time.Duration `ini:"dirlist-delay"` DirListTree bool `ini:"dirlist-tree"` + DirListCollapse int `ini:"dirlist-collapse"` Sort []string `delim:" "` NextMessageOnDelete bool `ini:"next-message-on-delete"` CompletionDelay time.Duration `ini:"completion-delay"` diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index aaf15b8a..f9a87580 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -207,6 +207,12 @@ These options are configured in the *[ui]* section of aerc.conf. Default: false +*dirlist-collapse* + If dirlist-tree is enabled, set level at which folders are collapsed + by default. Set to 0 to disable. + + Default: 0 + *next-message-on-delete* Moves to next message when the current message is deleted diff --git a/widgets/dirtree.go b/widgets/dirtree.go index 65fb3116..eb0af6ed 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -327,7 +327,7 @@ func (dt *DirectoryTree) buildTree() { copy(dt.treeDirs, dt.dirs) root := &types.Thread{Uid: 0} - buildTree(root, sTree, 0xFFFFFF) + dt.buildTreeNode(root, sTree, 0xFFFFFF, 1) threads := make([]*types.Thread, 0) @@ -373,7 +373,7 @@ func (dt *DirectoryTree) buildTree() { } } -func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) { +func (dt *DirectoryTree) buildTreeNode(node *types.Thread, stree [][]string, defaultUid uint32, depth int) { m := make(map[string][][]string) for _, branch := range stree { if len(branch) > 1 { @@ -398,7 +398,10 @@ func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) { } nextNode := &types.Thread{Uid: uid} node.AddChild(nextNode) - buildTree(nextNode, next, defaultUid) + if dt.UiConfig().DirListCollapse != 0 { + node.Hidden = depth > dt.UiConfig().DirListCollapse + } + dt.buildTreeNode(nextNode, next, defaultUid, depth+1) } } |