(Un)collapse ALL tagged threads in mutt

mutt

I'm trying to configure mutt so that whenever I switch to a folder, it collapses all threads by default, except those containing unread messages.

This is the folder hook I've written so far:

folder-hook . "push <collapse-all><tag-pattern>~(~N)<enter><tag-prefix-cond><collapse-thread>"
  • collapse-all collapses all threads;
  • tag-pattern: ~(~N) tags all visible (thread parent) messages belonging to threads containing unread messages;
  • tag-prefix-cond is supposed to make the next function apply to all tagged messages;
  • but it appears collapse-thread doesn't respond to the tag prefix (my guess is that's because it's written to act on threads, not messages).

So can this be done? (without writing a patch to mutt, that is?)

Best Answer

I think You do not even need a macro. There are configuration options regarding (un)collapsing.

Try following configuration and comment the macro:

set collapse_all = yes 
set uncollapse_new = no # (default is yes)