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
On 3/29/2022 6:12 AM, Jérôme LAURENS wrote: the tag is stores in the input state and reading from (pseudo) files as well as macro expansion and expanding pushed (back) token lists bump the pointer a line in tex is only reliable when it refers to a file; the extra synctex line states are global and can be used as overload but it assumes one knows where and what happens at that point the setters and getters are pretty simple and consistent: tag is stacked, the others aren't depending on what detail is enabled the synctex node line field get from the overloads or the built in line state handler one can of course maintain a purpose specific stack in lua \directlua{ tex.set_synctex_tag(11) tex.set_synctex_line(22) print("set value at level N :", status.input_ptr,11,22,tex.get_synctex_tag(),tex.get_synctex_line()) }\def\MyMacro{% \directlua{ tex.set_synctex_tag(111) tex.set_synctex_line(222) print("set value at level N+1:", status.input_ptr,111,222,tex.get_synctex_tag(),tex.get_synctex_line()) }} \MyMacro \directlua{ print("get value at level N :", status.input_ptr,tex.get_synctex_tag(),tex.get_synctex_line()) } \directlua{ tex.set_synctex_tag(11) tex.set_synctex_line(22) print("set value at level N :", status.input_ptr,11,22,tex.get_synctex_tag(),tex.get_synctex_line()) } \def\MyMacro{ \directlua{ tex.force_synctex_tag(111) tex.force_synctex_line(222) print("set force at level N+1:", status.input_ptr,111,222,tex.get_synctex_tag(),tex.get_synctex_line()) }} \MyMacro \directlua{ print("get value at level N :", status.input_ptr,tex.get_synctex_tag(),tex.get_synctex_line()) } \bye ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------