[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vile] setv for buffer-local variables?
From: |
Thomas Dickey |
Subject: |
Re: [vile] setv for buffer-local variables? |
Date: |
Fri, 24 Nov 2017 16:02:32 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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 ¬ &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 "¬ &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
--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: Digital signature