After one night, let me rephrase my feature request. I am aware that context has big problems with redirection but latex is also facing similar problems. I do not know the internals of synctex support in luatex but let me just infer that there is a storage for the tag and a storage for the line which are used as is when feeding the synctex attributes of the nodes. Let me call them <current tag> and <current line>. I assume also that there is a tag→ file name key value storage and a function to create a new entry in that table, let me call them <tag map> and <new entry>. I need a lua table named "synctex" with following methods synctex.set_tag(<n>): change <current tag> to <n> synctex.get_tag(<file>): if <file> == nil: return <current tag> If <file> is not a value of <tag map>: call <new entry> return the key for <file> in <tag map> synctex.set_line(<n>): change <current line> to <n> synctex.get_line(): get <current line> These cannot be replaced by the actual force methods which are too aggressive. Finally synctex.save_state, synctex.restore_state a public API to the already existing stack mechanism used by \input for example This will certainly solve the \openin and \read requests due to the callbacks. Being an addition, this low level implementation does not break anything existing. If you do not feel the need for such API, then I would be happy to propose a contribution when I know how to start.
Le 30 mars 2022 à 22:16, Hans Hagen
a écrit : There are situations where synctex info is not available: consider ``` \immediate\openin 0 {subfile.tex} \immediate\read 0 to \My \immediate\closein 0 \My \bye ``` Synctex does not see `subfile.tex` at all, which forbids any kind of synchronization between subfile.tex and main.pdf. It would be very cool if the \openin could create a new tag and the \read could use that tag while parsing subfile.tex. A synctex information about the line number would be very nice as well, a default of 1 is far better than nothing. A tex.get_synctex_tag_for_name(‘foo') would be extremely handy. Finally, raw setters and getters should be provided for synctex tag and line, to control exactly what tag and line is written to the .synctex file. No save stack for them, no mode. Simply raw. Some global synctex state stack would help: save_synctex_state/restore_synctex_state… BTW that would be great to deactivate set_synctex_tag for mode 0 just like set_synctex_line is.
On 3/30/2022 9:18 PM, Jérôme LAURENS wrote: the 'forced' tag and line always win and opening files is under callback control so basically one can (only) use those in combination with synctex mode set from the lua end; it has never been the intention to provide interfaces to synctex beyond forcing tag and line numbers that end up in nodes;
the only reason that there is that little bit of (lua) alternative interfacing is that in context we had to get around some limitations (afaiwn synctex works ok with plain latex but not that well with context so we had to hack around a bit) .. basically synctex support is just a black box as in the other tex engines and not really part of 'opening up the internals' (also because in the end the output should be useable by the synctex file interpretation code)
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl ----------------------------------------------------------------- _______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex