[luatex] Saving and Loading third party data in *.tuc files

Stephen Gaito stephen at perceptisys.co.uk
Tue Feb 2 15:22:08 CET 2021


Hello,

After a simple experiment I find that I *can* save third party data
into a ConTeXt *.tuc file using the "standard" `job.register` system.

Unfortunately, I suspect that the corresponding `job.load` happens
before my third party ConTeXt module is loaded so any `job.register`
happening inside my module's Lua code is too late to be loaded.

What is the correct way to save and load third party data to/from a
ConTeXt job's *.tuc file?

An extract of my (test) code is:
---------------------------------------------------------------------
thirddata            = thirddata            or { }
thirddata.pcontext   = thirddata.pcontext   or { }

local pcontext       = thirddata.pcontext

pcontext.subDocs     = pcontext.subDocs     or { }
local subDocs        = pcontext.subDocs

local function initializer()
  print("HELLO FROM pConTeXt initializer!")
end

local function finalizer()
  print("GOOD BYE FROM pConTeXt finalizer!")
end

job.register(
  'thirddata.pcontext.subDocs',
  'thirddata.pcontext.subDocs',
  initializer, finalizer
)
---------------------------------------------------------------------

And "evidence" that the `job.save` is working is the following:
---------------------------------------------------------------------
if not utilitydata.thirddata then utilitydata.thirddata = { } end
if not utilitydata.thirddata.pcontext then
utilitydata.thirddata.pcontext = { } end

utilitydata.thirddata.pcontext.subDocs={
}
---------------------------------------------------------------------

To be definite I am using LMTX:
---------------------------------------------------------------------
mtx-context     | ConTeXt Process Management 1.04
mtx-context     |
mtx-context     | main context file:
/home/XXXXXX/conTeXt/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context     | current version: 2020.12.28 01:41 mtx-context     |
main context file:
/home/XXXXXX/conTeXt/tex/texmf-context/tex/context/base/mkxl/context.mkxl
mtx-context     | current version: 2020.12.28 01:41
---------------------------------------------------------------------

Regards,

Stephen Gaito


More information about the luatex mailing list.