#3711: Request for collapse/uncollapse commands
--------------------------+------------------------------------------
Reporter: losingkeys | Owner: mutt-dev
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: mutt | Version:
Resolution: | Keywords: collapse,commands,uncollapse
--------------------------+------------------------------------------
Comment (by dgc):
This feels like an improvement to me, but I would not agree with changing
semantics of existing operations -- too many configurations and list posts
depend on exact behavior. I don't have time to hack on this right now,
but here's a suggestion to maybe minimize both user-facing changes and
implementation work.
1. Make `toggle-collapse` a synonym for `collapse-thread`. Likewise
`toggle-collapse-all`. Leave `collapse-thread[-all]` in place.
1. For each `toggle-*` operation, add a `-on` op and a `-off` op. E.g.
we end up with `toggle-new`, `toggle-new-on`, `toggle-new-off`.
1. Operations are generally implemented as inline code in very large case
switches. So `toggle-new`'s implemention begins with `case OP_TOGGLE_NEW`.
Functionalizing the code within each case is an option, but this code
tends to use a lot of the local scope and passing that context in/getting
updates back out might be messy (not sure). However, this code can be
modified for compact reuse with minor changes:
Current pseudocode:
{{{
case OP_TOGGLE_XYZ:
if (currently_on) /* standin for actual code */
set_to_off(); /* standin */
else
set_to_on(); /* standin */
break;
}}}
Future pseudocode:
{{{
int toggle = 1;
case OP_TOGGLE_XYZ:
toggle = 0; /* if XYZ, toggle (1 -> 0) */
/* fall through */
case OP_TOGGLE_XYZ_ON:
toggle *= -1; /* if XYZ, toggle (1 -> 0 -> 0); if XYZ_ON,
toggle (1 -> -1) */
/* fall through */
case OP_TOGGLE_XYZ_OFF:
toggle *= -1; /* if XYZ, toggle (1 -> 0 -> 0 -> 0); if XYZ_ON,
toggle (1 -> -1 -> 1); if XYZ_OFF, toggle (1 -> -1) */
/* fall through */
if (toggle == 0) /* OP_TOGGLE_XYZ */
toggle = currently_on() || -1;
if (toggle) /* OP_TOGGLE_XYZ or OP_TOGGLE_XYZ_ON */
set_to_on();
else /* OP_TOGGLE_XYZ or OP_TOGGLE_XYZ_OFF */
set_to_off();
break; /* finally */
}}}
... It's only a little voodoo, compared to what else is in mutt. And it
allows us to largely leave alone the code represented by
set_to_on()/set_to_off()/currently_on().
I don't think any default binding changes are needed for this, it's mostly
a matter of emplacing capabilities for macro authors.
--
Ticket URL: <http://dev.mutt.org/trac/ticket/3711#comment:1>
Mutt <http://www.mutt.org/>
The Mutt mail user agent