~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] Add basename option in dirlist-format

Details
Message ID
<20201024193408.31516-1-mkupfer99@gmail.com>
DKIM signature
pass
Download raw message
Patch: +15 -0
Add new format specifier %b for dirlist. Only the basename of the
directory is displayed. Each parent directory is replaced by two
whitespaces.

---
 doc/aerc-config.5.scd |  2 ++
 widgets/dirlist.go    | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index c96ea12..3d76c28 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -153,6 +153,8 @@ These options are configured in the *[ui]* section of aerc.conf.
:  literal %
|  %n
:  directory name
|  %b
:  basename of directory (replaces each parent directory by two whitespaces)
|  %r
:  recent/unseen/total message count
|  %>X
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index aca1491..3f7ad9b 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -6,6 +6,7 @@ import (
	"math"
	"regexp"
	"sort"
	"strings"

	"github.com/gdamore/tcell"
	"github.com/mattn/go-runewidth"
@@ -151,6 +152,18 @@ func (dirlist *DirectoryList) getDirString(name string, width int, recentUnseen
				formatted += name
				percent = false
			}
		case 'b':
			if percent {
				splitted := strings.Split(name, "/")
				basename := strings.Repeat(" ", (len(splitted)-1)*2)
				basename += splitted[len(splitted)-1]
				if rightJustify {
					doRightJustify(basename)
					rightJustify = false
				}
				formatted += basename
				percent = false
			}
		case 'r':
			if percent {
				rString := recentUnseen()
-- 
2.26.2
Details
Message ID
<20201025193525.odbhd5fydgisxbxh@feather.localdomain>
In-Reply-To
<20201024193408.31516-1-mkupfer99@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Hi,
Thank you for the patch, however this needs some improvements in order to be in
a proper shape to merge this.

For starters, your logic to split on '/' is too naive.
Just because you happen to be using '/' as a separator doesn't mean that everyone
else does.
In fact, the imap protocol tells the client what separator to expect (common are
'/' and '.', others are valid as well in theory).
For the notmuch worker, any marker can be used (the user can be very creative
with the names).

So you need to refactor the patch in order to accommodate different needs for different
workers, meaning at the very least bubble it up from the imap worker to the account.
Considering that this is send by the protocol itself, this should all happen
automatically without the user having to set a config option.

Second:
In my view we shouldn't try to indent children at all.
Consider the following example mailboxes:

```
inbox
fun/stuff
inbox/work
inbox/work/important
```

Now say the user is only interested in inbox/work/important but doesn't care
about its parent and has a filter set to hide the folder from the dirlist.
If you now set the index format to be %b it'll look like this:
(mind you, that's just me glancing at the code without actually running it)

```
inbox
  stuff
    important
```

See the problem?
The parent --> child relationship is totally messed up. 'important' now looks
like a child of inbox... important is even worse.

I'd rather just see

```
inbox
stuff
important
```

However, this gets nasty as soon as you have inbox/todo and work/todo... no way
to differentiate between the two.

Cheers,
Reto
Reply to thread Export thread (mbox)