[luatex] Inspecting a \def from LuaTeX

Hans Hagen pragma at wxs.nl
Tue Jan 30 09:13:02 CET 2018


On 1/29/2018 7:26 PM, Eduardo Ochs wrote:
> Hi list,
> 
> Is there a way to inspect the contents of a \def from Lua in LuaTeX?
> If I do, say,
> 
>    \def\hello{Hello}
> 
> I know how to see the sequence of tokens in \hello by running
> "\show\hello" in a TeX prompt... is there something similar that can
> be done from Lua?
You can try:

\starttext

\def\alpha#1#2{beta#1gamma#2delta}

\directlua{print(token.get_macro("alpha"))}
\directlua{print(token.get_meaning("alpha"))}

\directlua{print(token.set_macro("alpha","whatever"))}

\directlua{print(token.get_macro("alpha"))}
\directlua{print(token.get_meaning("alpha"))}

\stoptext

(these helpers still have a somewhat experimental status but they will 
stay)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list