On Mon, Mar 28, 2022 at 06:53:30PM +0200, Jérôme LAURENS wrote:
Things seem not as simple as you suggest, at least on luatex 1.13.2.
In next example, synctex_tag and synctex_line both survive the first \directlua call, so the state is not gone, which is a good thing
\directlua{ tex.set_synctex_tag(99) print(tex.get_synctex_tag()) tex.set_synctex_tag(199) tex.set_synctex_line(299) print(tex.get_synctex_line()) tex.set_synctex_line(399) } \directlua{ print(tex.get_synctex_tag()) print(tex.get_synctex_line()) } \bye
In next example where \directlua is called from a macro, synctex_line survives the call but not synctex_tag. So some part of the state is gone, which is not practical.
\def\Setter{ \directlua{ tex.set_synctex_tag(99) print(tex.get_synctex_tag()) tex.set_synctex_tag(199) tex.set_synctex_line(299) print(tex.get_synctex_line()) tex.set_synctex_line(399) } } \Setter \def\Getter{ \directlua{ print(tex.get_synctex_tag()) print(tex.get_synctex_line()) } } \Getter \bye
As Hans wrote the tag is set for the current input level. A macro expansion is a new input level, while \directlua in general is not (except of course if new input is added from the Lua code) - Marcel