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 <t...@2krueger.de> 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

Reply via email to