On 10/23/2022 12:34 AM, Eduardo Ochs wrote:
Hi list,

how do I use the function token.expand, that is (very) briefly
mentioned here?

   http://mirrors.ibiblio.org/CTAN/systems/doc/luatex/luatex.pdf#page=224

I've put this in a .tex file

   \def\foo{FOO}
   \def\bletch#1{BL#1ETCH}

and entered a Lua REPL. All the "print"s below give meaningful
results,

   print(token.get_macro("foo"))
   print(token.get_macro("bletch"))
   print(token.get_meaning("foo"))
   print(token.get_meaning("bletch"))
   print(token.create("bletch"))
   print(token.create("bletch").expandable)

and the last one says "true"... but I've tried to call token.expand
with several kinds of arguments, and in all cases I got this error,

   ! Undefined control sequence.
   \repl ->\directlua { print(); run_repl2_now() }

where \repl is the tex macro that I use to run my Lua REPL...
token.expand is rather useless and a left-over from earlier mechanisms that have been replaced (it's now kind of hard to make an example).

Anyway, you can best push a token into the input with tex.print:

\def\bletch#1{BL#1ETCH}

\directlua{tex.print(token.create("bletch"))}xxxxx
\directlua{tex.print(token.create("bletch"))}{xxx}xx

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
-----------------------------------------------------------------

Reply via email to