Neomutt: Nested virtual folders

Created on 8 Mar 2019  Â·  3Comments  Â·  Source: neomutt/neomutt

Hey folks, I've tried searching for this on the neomutt website and through a series of searches on duckduckgo and this issue list, but can't figure out if what I'm trying to do is feasible.

I'm using notmuch and virtual folders in neomutt and have dumped email from several accounts (work/personal/edu) into mailboxes. I've got the sidebar open on the left, and was hoping to replicate nested mailbox folders with virtual folder names. E.g. "INBOX" and "INBOX/Subscriptions" would have Subscriptions idented underneath INBOX.

I'm still learning mutt and have been cannabilizing mutt configurations from things I've seen, read, etc.
I don't know if nested virtual folders are possible. If they are, I don't know what I'm missing to do that. I've got an old sidebar_format that I haven't fully processed yet and will probably change, but I didn't think that would affect sidebar_folder_ident or the delimiter. But maybe the delimiter and whatnot doesn't work on virtual mailbox names?

I'd love for this to exist. If it doesn't, I could take a crack at adding support, but my inexperience with mutt (settings, etc) may be a problem.

My sidebar configuration

# Show the sidebar
set sidebar_visible=yes

# Display TODO
set sidebar_format="%B%?F? [%F]?%* %?N?%N/?%S"

# Sidebar is 30 characters wide
set sidebar_width=30

# Enable extended mailbox mode to calculate total, new, and flagged
# message counts for each mailbox
set mail_check_stats=yes

# Abbreviate mailbox names
set sidebar_short_path = yes

# Number of top-level mailbox path subdirectories to truncate for display
set sidebar_component_depth = 0

# Character to use when abbreviating mailbox names; only part after last
# separator is shown
set sidebar_delim_chars = '/.'

# Indent abbreviated mailboxes
set sidebar_folder_indent = yes

# Prefix for indention
set sidebar_indent_string = '  '

# When searching for mailboxes containing new mail, do not wrap the search
# around when it reaches the end of the list
set sidebar_next_new_wrap = no

# Keep sidebar on the left
set sidebar_on_right = no

# Mark sidebar divider character
set sidebar_divider_char = '|'

# Keep mailboxes in order provided in source
set sidebar_sort_method = 'unsorted'

My mailbox configuration

virtual-mailboxes "inbox" "notmuch://?query=tag:inbox"
virtual-mailboxes "inbox/personal" "notmuch://?query=tag:inbox and tag:personal"
virtual-mailboxes "inbox/gatech" "notmuch://?query=tag:inbox and tag:gatech"
virtual-mailboxes "inbox/vt" "notmuch://?query=tag:inbox and tag:vt"
virtual-mailboxes "inbox/work" "notmuch://?query=tag:inbox and tag:work"
virtual-mailboxes "archive" "notmuch://?query=tag:archive"
virtual-mailboxes "drafts" "notmuch://?query=tag:draft"
virtual-mailboxes "sent" "notmuch://?query=tag:sent"
virtual-mailboxes "spam" "notmuch://?query=tag:spam"

Results

screen shot 2019-03-08 at 1 00 55 pm

Ideal Appearance (indentation)

screen shot 2019-03-08 at 1 03 35 pm

discuss notmuch enhancement

Most helpful comment

Hi @chipsenkbeil

You're right, nested virtual folders don't work.

The email backends (maildir, imap, etc), don't have a concept of a hierarchy between folders. They just present a flat list.

The sidebar tries to generate a tree using the folders' paths (this is prone to error, but good enough).

  • trim the folder's path using $folder
  • compare against the previous mailbox's path

    • shallower path: clear indent

    • same prefix: same indent

    • deeper path: more indent

When using the Notmuch folders, the sidebar displays the folder's description field.
Unfortunately, this doesn't have the indenting rules applied to it.

I could take a crack at adding support

That'd be wonderful.

Fixing this would mean a little tinkering in:
https://github.com/neomutt/neomutt/blob/11488feb1de8022aa50e988d062155560c1be4c6/sidebar.c#L806

You're welcome to discuss the code here or on IRC: #neomutt on irc.freenode.net


Oh, btw, there's a workaround :-)

If you change your descriptions, you can fake a hierarchy:

virtual-mailboxes "inbox"      "notmuch://?query=tag:inbox"
virtual-mailboxes "  personal" "notmuch://?query=tag:inbox and tag:personal"
virtual-mailboxes "  gatech"   "notmuch://?query=tag:inbox and tag:gatech"
virtual-mailboxes "  vt"       "notmuch://?query=tag:inbox and tag:vt"
virtual-mailboxes "  work"     "notmuch://?query=tag:inbox and tag:work"
virtual-mailboxes "archive"    "notmuch://?query=tag:archive"
virtual-mailboxes "drafts"     "notmuch://?query=tag:draft"
virtual-mailboxes "sent"       "notmuch://?query=tag:sent"
virtual-mailboxes "spam"       "notmuch://?query=tag:spam"

All 3 comments

Hi @chipsenkbeil

You're right, nested virtual folders don't work.

The email backends (maildir, imap, etc), don't have a concept of a hierarchy between folders. They just present a flat list.

The sidebar tries to generate a tree using the folders' paths (this is prone to error, but good enough).

  • trim the folder's path using $folder
  • compare against the previous mailbox's path

    • shallower path: clear indent

    • same prefix: same indent

    • deeper path: more indent

When using the Notmuch folders, the sidebar displays the folder's description field.
Unfortunately, this doesn't have the indenting rules applied to it.

I could take a crack at adding support

That'd be wonderful.

Fixing this would mean a little tinkering in:
https://github.com/neomutt/neomutt/blob/11488feb1de8022aa50e988d062155560c1be4c6/sidebar.c#L806

You're welcome to discuss the code here or on IRC: #neomutt on irc.freenode.net


Oh, btw, there's a workaround :-)

If you change your descriptions, you can fake a hierarchy:

virtual-mailboxes "inbox"      "notmuch://?query=tag:inbox"
virtual-mailboxes "  personal" "notmuch://?query=tag:inbox and tag:personal"
virtual-mailboxes "  gatech"   "notmuch://?query=tag:inbox and tag:gatech"
virtual-mailboxes "  vt"       "notmuch://?query=tag:inbox and tag:vt"
virtual-mailboxes "  work"     "notmuch://?query=tag:inbox and tag:work"
virtual-mailboxes "archive"    "notmuch://?query=tag:archive"
virtual-mailboxes "drafts"     "notmuch://?query=tag:draft"
virtual-mailboxes "sent"       "notmuch://?query=tag:sent"
virtual-mailboxes "spam"       "notmuch://?query=tag:spam"

Cool, thanks for pointing out a place to start! I'll take a look at it and see if I can do something.

And, thanks for the workaround! I grabbed that and used it, so at least I get the appearance that I want for now!

[EDIT]

From looking through the function you pointed out, I think I have a place to start. I was looking through the test directory and it doesn't appear like any of the logic from the sidebar has been tested. Or am I looking in the wrong place?

While testing the actual drawing function would be hard, I could try to break out some of the internal logic into helper methods that could be tested. For example, checking the output of shortening and indenting the folder name (before it's drawn) to make sure it looks right.

I can try to follow up on IRC later, but for now I'll try to get the project building and see if the changes I make do what I expect.


On Sat, Mar 09, 2019 at 04:33:41AM -0800, Richard Russon wrote:

Hi @chipsenkbeil

You're right, nested virtual folders don't work.

The email backends (maildir, imap, etc), don't have a concept of a hierarchy between folders. They just present a flat list.

The sidebar tries to generate a tree using the folders' paths (this is prone to error, but good enough).

  • trim the folder's path using $folder
  • compare against the previous mailbox's path

    • shallower path: clear indent

    • same prefix: same indent

    • deeper path: more indent

When using the Notmuch folders, the sidebar displays the folder's description field.
Unfortunately, this doesn't have the indenting rules applied to it.

I could take a crack at adding support

That'd be wonderful.

Fixing this would mean a little tinkering in:
https://github.com/neomutt/neomutt/blob/11488feb1de8022aa50e988d062155560c1be4c6/sidebar.c#L806

You're welcome to discuss the code here or on IRC: #neomutt on irc.freenode.net


Oh, btw, there's a workaround :-)

If you change your descriptions, you can fake a hierarchy:

virtual-mailboxes "inbox"      "notmuch://?query=tag:inbox"
virtual-mailboxes "  personal" "notmuch://?query=tag:inbox and tag:personal"
virtual-mailboxes "  gatech"   "notmuch://?query=tag:inbox and tag:gatech"
virtual-mailboxes "  vt"       "notmuch://?query=tag:inbox and tag:vt"
virtual-mailboxes "  work"     "notmuch://?query=tag:inbox and tag:work"
virtual-mailboxes "archive"    "notmuch://?query=tag:archive"
virtual-mailboxes "drafts"     "notmuch://?query=tag:draft"
virtual-mailboxes "sent"       "notmuch://?query=tag:sent"
virtual-mailboxes "spam"       "notmuch://?query=tag:spam"

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/neomutt/neomutt/issues/1594#issuecomment-471173244

I'll take a look at it and see if I can do something

Great.

it doesn't appear like any of the logic from the sidebar has been tested

Correct. We've made a (small) start on testing things -- see /test and make test. These work on the two blocks of code that are independent of NeoMutt: /mutt and /config.

Other than that, it's very hard to isolate the code.

I could try to break out some of the internal logic into helper methods

Yes, that'd be helpful.

I can try to follow up on IRC later

I'm always logged in.
Feel free to ask lots of questions.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings