In realgud I have a text button that needs access to a dynamically-bound buffer-local variable.
The situation occurs like this. Inside one buffer that has the buffer local variable, there is a command that creates another "Describe" buffer with the value of that complex defstruct
variable formatted nicely using org mode.
But inside that "Describe" buffer I would like to have a button that calls describe-variable
on the variable, but have that use the value from its original buffer location, not the value in the describe buffer.
Currently I have inside insert-text-button
an action property like this:
'action '(lambda(button) (describe-variable 'realgud-cmdbuf-info))
However this gives picks up the wrong buffer-local value. I can't change the above say to:
'action '(lambda(button) (with-current-buffer buffer (describe-variable 'realgud-cmdbuf-info)))
because of the quote in front of the lambda, and because with-current-buffer
is a macro. Changing that to start `list('lambda(button) would be cumbersome if I could figure it out.
Probably I need to use some macro here, but that also is beyond my comprehension.
Help?
`
buffer
is defined.buffer
is bound in this scope, all you have to do is remove the quote beforelambda
and enablelexical-binding
in the .el file. Alternatively use a backquote`
and then splice it in with,
as suggested. What ever you do don't single-quotelambda
s, unless you want it to be treated as constant data, e.g. by the compiler.