Re: Toggling between two values of a string variable?

2020-06-28 Thread Tom Ryder

On Sat, Jun 27, 2020 at 08:48:15PM -0400, John Hawkinson wrote:
Ideally I'd like to bind a key to toggle between two values of a string 
variable. There doesn't seem to be a good way to accomplish this -- is 
there a trick?


I've seen a few different ways to do this, but this is how I'm doing it 
for toggling thread display, with a user variable (`$my_...`):


# Shortcut to toggle thread display
set sort = date
set my_sort_alt = threads
macro index \\t '\
set my_sort_cur = $sort\
set sort = $my_sort_alt\
set my_sort_alt = $my_sort_cur' \
"Toggle thread display"

So backslash-T toggles between the values "date" and "threads".  I'm 
aware of using dynamically-sourced files for this, per the ConfigTricks 
section of the manual, but that approach is not my cup of tea.


--
Tom Ryder 
Maybe we can bring back the light.


Re: Toggling between two values of a string variable?

2020-06-27 Thread Kevin J. McCarthy

On Sun, Jun 28, 2020 at 03:15:12AM +0200, Francesco Ariis wrote:

Il 27 giugno 2020 alle 20:48 John Hawkinson ha scritto:
Ideally I'd like to bind a key to toggle between two values of a 
string variable. There doesn't seem to be a good way to accomplish 
this -- is there a trick?


I recall a similar question being asked on this ML — or was it IRC? — 
in the past and this link providing the answer:


   https://gitlab.com/muttmua/mutt/-/wikis/ConfigTricks

specifically the «(ab)use "macros" as variables» section.
Would that do?


I think the same basic idea, but using macro redefinition instead, was 
posted by David Champion a few years ago: 
.


The message is misformatted in that page, but the 'raw body' link is 
readable.


--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA


signature.asc
Description: PGP signature


Re: Toggling between two values of a string variable?

2020-06-27 Thread Francesco Ariis
Hello John,

Il 27 giugno 2020 alle 20:48 John Hawkinson ha scritto:
> Ideally I'd like to bind a key to toggle between two values of a
> string variable. There doesn't seem to be a good way to accomplish
> this -- is there a trick?

I recall a similar question being asked on this ML — or was it IRC? — in
the past and this link providing the answer:

https://gitlab.com/muttmua/mutt/-/wikis/ConfigTricks

specifically the «(ab)use "macros" as variables» section.
Would that do?
—F


Toggling between two values of a string variable?

2020-06-27 Thread John Hawkinson
I feel like this is a silly question, but here goes:

I've recently found myself toggling back and forth the "postponed" variable 
to deal with either postponing messages locally (no network dependancy!) or 
dealing with postponed messages in a remote IMAP mailbox for collaboration with 
a mobile client (e.g. Gmail's Drafts folder).

Experience has shown there is no one right answer, I need to use one 
definition of postponed sometimes, and one the other.

Ideally I'd like to bind a key to toggle between two values of a string 
variable. There doesn't seem to be a good way to accomplish this -- is there a 
trick?

As an alternative, I (notionally) bound ,a to :set postponed to one value, 
and ,b to :set it to another. I do not love this. Both display the result (:set 
?postponed\n) so I can at least see what I've done.

I realize on some level this is plea for macro/scripting language with true 
conditionals, and we're not going to get there anytime soon. The last time I 
had a problem of this nature in mutt I bound the macro to ! execute a perl 
script that did its thing and then made use of the fact that mutt was running 
under screen(1) and used screen's "slowpaste" to tell mutt to :source a 
temporary file that redefined things as desired. Since my mutt isn't running 
under screen anymore (although I suppose I could), this approach doesn't work, 
and it was pretty janky anyhow.

I guess it's collateral, but I was surprised that I couldn't get :toggle to 
work with a $my_foo variable. I guess it would not really have helped me make 
progress, but seemed like it could be a building block in some more complex 
scheme.


Thanks for any thoughts.

--
jh...@alum.mit.edu
John Hawkinson