blefloch / latex-unravel

Watching TeX digest tokens
24 stars 1 forks source link

LuaTeX expandable luacall #46

Closed blefloch closed 3 years ago

blefloch commented 3 years ago

LuaTeX has "new" ways of accessing Lua, through expandable luacalls. This is for instance used in \file_size:n. Currently breaks in unravel.

blefloch commented 3 years ago

These are defined by \luadef (or \protected\luadef and so on). From the meaning we can extract the number #1, then get lua.get_functions_table()[#1] on the Lua side, patch it with something that gives control back to unravel.

\directlua
  {
      lua.get_functions_table()[#1](#1)
      unravel.main_loop()
  }
  ... rest of the input stream, like we do for macros.

where unravel.main_loop() inserts the right \__unravel_... command.