On 9/20/2014 2:45 PM, Christoph Reller wrote:
Two general questions arise (if your permit):
1. Where are the key-value pairs stored? In your first solution you handle the key setting by explicitly calling lua on every \setup<name> call. It seems that all key-value pairs (that are set with \installcommandhandler-generated \setup<name>) are stored on the TeX side and not on the lua side. Is this correct?
yes and getting the macro meaning at the lua end is not efficient as it is tokenized
2. Calling \ctxlua from lua. I was tempted to add another level of indirection to your second (the "synchronize") solution. I.e: in the lua code (in a separate lua file to avoid the do ... end introduced by \startluacode .... \stopluacode) I have:
n = "" v = "" function getkey(name,value) n = name v = value end function myfun(parameters,content) context([[\ctxlua{getkey("gkey","\elemparameter{gkey}")}]]) context(" name=") context(n) context(", value=") context(v) end
The above does not work because the value obtained "lags behind", i.e. initially v will be "", on the second call v will have the value of the first \setupelem[gkey=gval], and so on. I guess this lag is due to the way TeX and lua communicate to each other?
indeed, all printed to tex is injected into the input after the lua call ends
A small question: What do you mean by "there is no grouping in lua"?
\bgroup ... some assignment at the tex end ... followed by setting it in lua \bgroup ... forgotten at the tex end ... still set at the lua end
Thank you anyway for your valuable input.
Regards, Christoph
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------