summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/core-uti.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-04-18 22:52:45 +0000
committerKarl Berry <karl@freefriends.org>2015-04-18 22:52:45 +0000
commit16aa5a7c87f18a2483d0d61795899f886781b51c (patch)
tree1d72f00b2a4185425393598402fe055c61d1de58 /Master/texmf-dist/tex/context/base/core-uti.lua
parente68dc4d5506d46bf72823234f902bc76d1f70352 (diff)
context, from www.pragma-ade.com/context/beta/cont-tmf.zip (18apr15)
git-svn-id: svn://tug.org/texlive/trunk@36923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-uti.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/core-uti.lua74
1 files changed, 65 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-uti.lua b/Master/texmf-dist/tex/context/base/core-uti.lua
index 1903ad8236b..346dec89e9e 100644
--- a/Master/texmf-dist/tex/context/base/core-uti.lua
+++ b/Master/texmf-dist/tex/context/base/core-uti.lua
@@ -29,6 +29,8 @@ local packers = utilities.packers
local allocate = utilities.storage.allocate
local mark = utilities.storage.mark
+local implement = interfaces.implement
+
local texgetcount = tex.getcount
local report_passes = logs.reporter("job","passes")
@@ -36,7 +38,7 @@ local report_passes = logs.reporter("job","passes")
job = job or { }
local job = job
-job.version = 1.25
+job.version = 1.29
job.packversion = 1.02
-- some day we will implement loading of other jobs and then we need
@@ -62,21 +64,35 @@ end
job.comment("version",job.version)
-local enabled = true
+local enabled = true
+local initialized = false
directives.register("job.save",function(v) enabled = v end)
+----------.register("job.keep",function(v) kept = v end)
function job.disablesave() -- can be command
enabled = false
end
function job.initialize(loadname,savename)
- job.load(loadname) -- has to come after structure is defined !
- luatex.registerstopactions(function()
- if enabled and not status.lasterrorstring or status.lasterrorstring == "" then
- job.save(savename)
+ if not initialized then
+ if not loadname or loadname == "" then
+ loadname = tex.jobname .. ".tuc"
+ end
+ if not savename or savename == "" then
+ savename = tex.jobname .. ".tua"
end
- end)
+ job.load(loadname) -- has to come after structure is defined !
+ luatex.registerstopactions(function()
+ if enabled and not status.lasterrorstring or status.lasterrorstring == "" then
+ -- if kept then
+ -- job.keep(loadname) -- could move to mtx-context instead
+ -- end
+ job.save(savename)
+ end
+ end)
+ initialized = true
+ end
end
function job.register(collected, tobesaved, initializer, finalizer, serializer)
@@ -283,6 +299,28 @@ function job.loadother(filename)
statistics.stoptiming(_load_)
end
+-- function job.keep(filename)
+-- local suffix = file.suffix(filename)
+-- local base = file.removesuffix(filename)
+-- if suffix == "" then
+-- suffix = "tuc"
+-- end
+-- for i=1,10 do
+-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,i)
+-- if lfs.isfile(tmpname) then
+-- os.remove(tmpname)
+-- report_passes("removing %a",tmpname)
+-- end
+-- end
+-- if lfs.isfile(filename) then
+-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,environment.currentrun or 1)
+-- report_passes("copying %a into %a",filename,tmpname)
+-- file.copy(filename,tmpname)
+-- else
+-- report_passes("no file %a, nothing kept",filename)
+-- end
+-- end
+
-- eventually this will end up in strc-ini
statistics.register("startup time", function()
@@ -352,6 +390,24 @@ function statistics.formatruntime(runtime)
end
end
+implement {
+ name = "savevariable",
+ actions = job.variables.save,
+ arguments = { "string", "string" }
+}
-commands.savevariable = job.variables.save
-commands.setjobcomment = job.comment
+implement {
+ name = "setjobcomment",
+ actions = job.comment,
+ arguments = { { "*" } }
+}
+
+implement {
+ name = "initializejob",
+ actions = job.initialize
+}
+
+implement {
+ name = "disablejobsave",
+ actions = job.disablesave
+}