vile
[Top][All Lists]
Advanced

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

Re: [vile] setv for buffer-local variables?


From: Wayne Cuddy
Subject: Re: [vile] setv for buffer-local variables?
Date: Fri, 24 Nov 2017 18:03:18 -0500
User-agent: Mutt/1.6.1 (2016-04-27)

On Fri, Nov 24, 2017 at 04:02:32PM -0500, Thomas Dickey wrote:
> On Fri, Nov 24, 2017 at 01:59:56PM -0500, Wayne Cuddy wrote:
> > 
> > I have a procedure that toggles boolean variables using setv. The
> > problem with this is that setv seems to adjust that corresponding
> > variable in all buffers.  What is the equivalent setl in vile's macro
> > language?
> > 
> > This is the offending line:
> >     setv &indirect $1 &not &indirect %mode
> > 
> > Note the name of the variable is determined/evaluated at execution
> > time using &indirect.  Replacing setv with setl does not work.
> > 
> > Or is there a way to build up a string and execute it... something
> > like sh's eval command?
> 
> yes - it's not pretty, but you can use &cat for concatenating strings.
> It would look something like this:
> 
>      eval &cat "setv &indirect" &cat $1 "&not &indirect %mode"
> 
> it-would-be-nice-if-vile-implemented "&sprintf"
>  
> > I see execute-string exists but it doesn't seem to be callable from
> > the macro language?
> 
> I use eval (execute-string) in this macro in vileinit.rc:
> 
> ; generalized from ToggleList, for any boolean mode
> store-procedure ToggleMode mode='Mode'
>       ~local %value
>       setv %value &local $1
>       ~if &seq "TRUE" %value
>               eval &cat "setl no" $1
>       ~elseif &seq "FALSE" %value
>               eval &cat "setl " $1
>       ~else
>               write-message "Not a boolean mode"
>       ~endif
> ~endm
> 
> -- 

Exactly what I was looking for. Darn, I checked the help page and macros
file and didn't see anything about eval, though I forgot to check the
sample vileinit.rc. Is it documented somewhere or am I just blind in my
old age?

Thanks again,
Wayne 



reply via email to

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