~rjarry/aerc#175: 
Allow remapping imap folder names to user defined foldernames.

This feature would be useful for example for gmail users, where you could remap [GMAIL]/X folders to just plain X.

It could be configured similary to notmuch query-maps, i.e. by configuring a folder-map entry in accounts which points to a file with lines like [GMAIL]/X = X.

Status
RESOLVED FIXED
Submitter
~ferdinandyb
Assigned to
No-one
Submitted
10 months ago
Updated
8 months ago
Labels
feature imap

~konimarti 10 months ago

I don't think we need a folder map for this. We can already handle this using templates in the dirlist-left config. For example, you could do the following:

dirlist-left =  {{if (eq .Account "Gmail")}} \
                         {{- .Folder | exec "sed 's/\\[Gmail\\]\\///'" -}} \
                 {{else}} \
                         {{- .Folder | compactDir -}} \
                 {{end}}

However, this is currently super slow because the dirlist is redrawn so many times and it's an external command. A better approach would be to add a template function such as 'replace' and map it to strings.ReplaceAll:

{{- .Folder | replace "[Gmail]/" "" -}} \

Or the filepath.Base function could be an option, too.

What do you think?

~ferdinandyb 10 months ago

On Fri May 12, 2023 at 22:42, ~konimarti wrote:

I don't think we need a folder map for this. We can already handle this using templates in the dirlist-left config. For example, you could do the following:

dirlist-left =  {{if (eq .Account "Gmail")}} \
                         {{- .Folder | exec "sed 's/\\[Gmail\\]\\///'" -}} \
                 {{else}} \
                         {{- .Folder | compactDir -}} \
                 {{end}}

However, this is currently super slow because the dirlist is redrawn so many times and it's an external command. A better approach would be to add a template function such as 'replace' and map it to strings.ReplaceAll:

{{- .Folder | replace "[Gmail]/" "" -}} \

Or the filepath.Base function could be an option, too.

What do you think?

This solution only rewrites the display name, but leaves the actual name (the one that can be used with commands like :cf) the same. I think that actually makes the situation a bit worse, because it just hides whatever is underneath. My goal is to be able to completely remap the folder so if I have a [GMAIL]/label -> label remap, then all aerc commands would operate on "label" instead of [GMAIL]/label.

~konimarti 10 months ago

Ok, makes sense.

~rjarry REPORTED FIXED 8 months ago

Koni Marti referenced this ticket in commit 0f37a0c.

Register here or Log in to comment, or comment via email.