vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] toggle boolean settings


From: Thomas Dickey
Subject: Re: [vile] toggle boolean settings
Date: Wed, 29 Feb 2012 17:15:36 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Feb 29, 2012 at 01:51:46PM -0500, address@hidden wrote:
> Is there a way to simply negate boolean settings? If not it would be
> nice to have a feature like this:
> 
> setl !list
> or
> setl notlist
> 
> If listing is enabled it would be disabled, else enabled.

I do this with a macro ToggleList, for just the special case of the list
mode.  That, and ToggleTabs have been useful enough as is, that I hadn't
considered making it more general.

One way to make it more general would be to make something like this
work (that is, gluing "$" onto the mode name and feeding that into
the interpretation):

        store-procedure invert mode="Mode to invert"
        write-message &cat "Hello:" $*
        ~if &cat "$" $1
        write-message &cat "HI:" $*
        ~else
        ~if $list
        write-message &cat "OOPS:" $*
        ~else
        write-message &cat "BYE:" $*
        ~endif
        ~endif
        ~endm

A quick check showed me it doesn't work, but that's the sort of thing
that macros would be good for.  (I also considered "eval" for the "~if"
line, but the "~" and "&" stuff _is_ processed before that, so it
wouldn't work).

A command to invert a boolean mode would be simpler to implement than
the examples you gave, in terms of how name-completion is constructed. 
That is, the command would have to make a subset of the modes which are
shown now - including strings and numbers.  After that, it could reuse
the existing logic for setting modes.

The "!" in contrast would be sort of magic, with the interpreter looking
for _that_ before deciding what it might use to complete things.

Likewise, the "not" prefix would be (like the current behavior for "no")
sort of magical, but less workable due to the existing modes that begin
with "t".

So... do you need generality, or can a special-purpose macro do what
you need?

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]