I'm stumped on this one, and I'm embarrassed to say how long I've spent on it. I like to see threads in neomutt index, but I'd like to be able to toggle thread settings between these two settings:
# use threads
set use_threads=reverse sort=last-date sort_aux=last-date
# don't use threads
set use_threads=no sort=reverse-date-sent
I can get this working through two separate macros:
macro index <tab> "<enter-command>set use_threads=reverse sort=last-date sort_aux=last-date<enter>"
macro index <backtab> "<enter-command>set use_threads=no sort=reverse-date-sent<enter>"
My hope was to use <tab>
to toggle between the two settings, but I can't figure out how to build if ? then : else
into a single macro.
I tried creating a shell script to help offload the logic, but I couldn't figure out how to send the current value of $use_threads to the script.
I can't remember where I found this, so I can't credit the source unfortunately. I'm not sure if there is a simpler way, but one trick is to have separate conflicting configuration files defining the macro, and source the other file in each config. This essentially switched what is mapped to the macro key each time you press it. In your case,
In file
~/.mutt/sources/threads.rc
In file
~/.mutt/sources/no_threads.rc
Then in your main
muttrc
, just source what you want as your default, e.g.