On Sun, Jun 20, 2010 at 07:21:47PM +0100, Michael Treibton wrote:
> hi
> 
> i have this -
> 
> SetEnv numofterms 10
> key q R A Echo $[numofterms]
> 
> which works. but when i change "numofterms" to be a different number,
> my key binding still shows "10".
> 
> why? is it a bug?

Ah.  You've been hit by the "expansion problem".  It's not a bug, it's just
that we're exposing FVWM's internals to the user again.  :)

When FVWM encounters a line such as:

Key q R A Echo $[numofterms]

It will expand that, to be (in your case):

Echo 10

So the full line might look like this (although note that this isn't how
FVWM stores it or anything, I am just doing this for ease of explanation):

Key q R A Echo 10

Which means now, that $[numofterms] has been interpolated out fully -- and
won't ever be interpolated again.

What you need to "fix" your problem is this:

Key q R A Echo $$[numofterms]

And, as in the above, you need to read the thing backwards, just like FVWM
is doing when it parses the line.  So first time around (when it encounters
the keyword "Key") FVWM will expand it out like this:

Key q R A Echo $[numofterms]

Then, when the action for the "q" binding is encountered, FVWM still sees to
run:

Echo $[numofterms]

... thus honouring the expansion of $[numofterms] for no matter how many
times you might change this environment variable.

Is that clear?  The trick is to read these things backwards -- and you need
two "$"s -- one for the Echo command, the other for the Key command.

If you, or anyone else, feels this information needs adding to the man page
or making clearer, *please* send me a patch.  It would save me a lot of
time.  :)

Kindly,

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)

Reply via email to