[NTG-context] Evaluating a Lua expression at the end (repeat)

Kumar Appaiah kumar.mlist at gmail.com
Fri Aug 26 05:57:55 CEST 2016


On Thu, Aug 25, 2016 at 5:49 PM, Henri Menke <henrimenke at gmail.com> wrote:
> Hi Kumar,
>
> the function job.variables.save seems to save the key in job.variables.collected.macros instead of job.variables.collected.  The problem is that macros is not created unconditionally, which is why you might run into a »attempt to index a nil value« error without some manual error checking.  Therefore I recommend assigning the temp value to job.variables.tobesaved["document:temp:"..name].  Perhaps Hans joins this discussion and schools me about why this could be a bad idea, but so far it works.
>
> Also, I'd recommend making all your user level macros protected and check for the optional argument in \startwhatever (otherwise you'll get errors like »Macro doesn't match its definition«).  Because I'm really cautious I also use \luaescapestring{#1} (Try for example »foo"bar« as a value without).


<snipped code>

Indeed, this worked! I'll try to understand the internals myself to
know what is going on exactly. Thanks for the solution.

Kumar


More information about the ntg-context mailing list