I think I know understand what is really meant by "obeys save stack" in the documentation, but that was not easy to catch due to 3 bugs in the implementation: contrary to the documentation 1 - force_synctex_tag obeys save stack 2 - set_synctex_line does not obey save stack 3 - force_synctex_line obeys save stack \directlua{ tex.set_synctex_tag(11) tex.set_synctex_line(22) }\def\MyMacro{ \directlua{ tex.set_synctex_tag(111) tex.set_synctex_line(222) }} \MyMacro \directlua{ print("SUCCESS 11 expected:", tex.get_synctex_tag()) print("FAILURE 22 expected:", tex.get_synctex_line()) } \directlua{ tex.set_synctex_tag(11) tex.set_synctex_line(22) } \def\MyMacro{ \directlua{ tex.force_synctex_tag(111) tex.force_synctex_line(222) }} \MyMacro \directlua{ print("FAILURE 111 expected:", tex.get_synctex_tag()) print("FAILURE 222 expected:", tex.get_synctex_line()) } \bye
Le 28 mars 2022 à 21:09, Jérôme LAURENS
a écrit : I have a better understanding now, but the problem still remains that synctex_tag and synctex_line are not managed accordingly, as illustrated by all the examples given so far. My first thinking was that synctex_tag behavior should follow synctex_line behavior, now it clearly appears that synctex_line should follow synctex_tag instead.
Consider next code ``` \directlua{ tex.set_synctex_tag(99) tex.set_synctex_line(299) } \MyMacro \directlua{ print(tex.get_synctex_tag()) print(tex.get_synctex_line()) } \bye ``` Whatever \MyMacro is, synctex_tag is 99, but synctex_line is unpredictable. That is a problem.
Le 28 mars 2022 à 19:46, Marcel Fabian Krüger
a écrit : 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
_______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex