diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-04-16 13:20:40 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-04-16 13:20:40 +0200 |
commit | 218228536ed709be8ab2dde4a00dc27249ceed8a (patch) | |
tree | 71b331e3d99ebd89fefcc1cb369d233c5c7fbdc1 /scripts/context/lua/mtx-context.lua | |
parent | ea2466fe69bd082d379e95e1567f3de0b76de243 (diff) | |
download | context-218228536ed709be8ab2dde4a00dc27249ceed8a.tar.gz |
2017-04-16 12:47:00
Diffstat (limited to 'scripts/context/lua/mtx-context.lua')
-rw-r--r-- | scripts/context/lua/mtx-context.lua | 165 |
1 files changed, 88 insertions, 77 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index b52bed379..6863cffb2 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['mtx-context'] = { +if not modules then modules = { } end modules['mtx-context'] = { version = 1.001, comment = "companion to mtxrun.lua", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -34,7 +34,7 @@ local formatters = string.formatters local application = logs.application { name = "mtx-context", - banner = "ConTeXt Process Management 1.00", + banner = "ConTeXt Process Management 1.01", -- helpinfo = helpinfo, -- table with { category_a = text_1, category_b = text_2 } or helpstring or xml_blob helpinfo = "mtx-context.xml", } @@ -159,6 +159,67 @@ local defaultformats = { "cont-nl", } +-- purging files (we should have an mkii and mkiv variants) + +local generic_files = { + "texexec.tex", "texexec.tui", "texexec.tuo", + "texexec.tuc", "texexec.tua", + "texexec.ps", "texexec.pdf", "texexec.dvi", + "cont-opt.tex", "cont-opt.bak" +} + +local obsolete_results = { + "dvi", +} + +local temporary_runfiles = { + "tui", -- mkii two pass file + "tua", -- mkiv obsolete + "tup", "ted", "tes", -- texexec + "top", -- mkii options file + "log", -- tex log file + "tmp", -- mkii buffer file + "run", -- mkii stub + "bck", -- backup (obsolete) + "rlg", -- resource log + "ctl", -- + "mpt", "mpx", "mpd", "mpo", "mpb", -- metafun + "prep", -- context preprocessed + "pgf", -- tikz + "aux", "blg", -- bibtex +} + +local temporary_suffixes = { + "prep", -- context preprocessed +} +local synctex_runfiles = { + "synctex", "synctex.gz", "syncctx" -- synctex +} + +local persistent_runfiles = { + "tuo", -- mkii two pass file + "tub", -- mkii buffer file + "top", -- mkii options file + "tuc", -- mkiv two pass file + "bbl", -- bibtex +} + +local special_runfiles = { + "%-mpgraph", "%-mprun", "%-temp%-" +} + +local function purge_file(dfile,cfile) + if cfile and validfile(cfile) then + if removefile(dfile) then + return filebasename(dfile) + end + elseif dfile then + if removefile(dfile) then + return filebasename(dfile) + end + end +end + -- process information local ctxrunner = { } -- namespace will go @@ -520,10 +581,15 @@ local function run_texexec(filename,a_purge,a_purgeall) end end --- +-- context mode will become the only method some day -local function check_synctex(a_synctex) - return a_synctex and (tonumber(a_synctex) or (toboolean(a_synctex,true) and 1) or (a_synctex == "zipped" and 1) or (a_synctex == "unzipped" and -1)) or nil +local function check_synctex(a_synctex) -- context is intercepted elsewhere + return a_synctex and ( + tonumber(a_synctex) or + (toboolean(a_synctex,true) and 1) or + (a_synctex == "zipped" and 1) or + (a_synctex == "unzipped" and -1) + ) or nil end function scripts.context.run(ctxdata,filename) @@ -583,7 +649,7 @@ function scripts.context.run(ctxdata,filename) local a_nonstopmode = getargument("nonstopmode") local a_scollmode = getargument("scrollmode") local a_once = getargument("once") - local a_synctex = getargument("synctex") + local a_synctex = getargument("syncctx") and "context" or getargument("synctex") local a_backend = getargument("backend") local a_arrange = getargument("arrange") local a_noarrange = getargument("noarrange") @@ -609,7 +675,7 @@ function scripts.context.run(ctxdata,filename) -- a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or (a_scrollmode and "scrollmode") or nil - a_synctex = check_synctex(a_synctex) + -- a_synctex = check_synctex(a_synctex) -- for i=1,#filelist do -- @@ -636,7 +702,7 @@ function scripts.context.run(ctxdata,filename) -- local analysis = preamble_analyze(filename) -- - a_synctex = a_synctex or check_synctex(analysis.synctex) + a_synctex = a_synctex or analysis.synctex -- if a_mkii or analysis.engine == 'pdftex' or analysis.engine == 'xetex' then run_texexec(filename,a_purge,a_purgeall) @@ -744,9 +810,9 @@ function scripts.context.run(ctxdata,filename) -- local l_flags = { ["interaction"] = a_batchmode, - ["synctex"] = a_synctex, - ["no-parse-first-line"] = true, -- obsolete - ["safer"] = a_safer, + ["synctex"] = check_synctex(a_synctex), -- otherwise not working + ["no-parse-first-line"] = true, -- obsolete + ["safer"] = a_safer, -- better use --sandbox -- ["no-mktex"] = true, -- ["file-line-error-style"] = true, ["fmt"] = formatfile, @@ -778,10 +844,13 @@ function scripts.context.run(ctxdata,filename) directives[#directives+1] = format("system.profile=%s",tonumber(a_profile) or 0) end -- + for i=1,#synctex_runfiles do + removefile(fileaddsuffix(jobname,synctex_runfiles[i])) + end if a_synctex then - report("warning: synctex is enabled") -- can add upto 5% runtime directives[#directives+1] = format("system.synctex=%s",a_synctex) end + -- if #directives > 0 then c_flags.directives = concat(directives,",") end @@ -836,6 +905,9 @@ function scripts.context.run(ctxdata,filename) -- end -- + if a_synctex == "context" then + renamefile(fileaddsuffix(jobname,"syncctx"),fileaddsuffix(jobname,"synctex")) + end if a_arrange then -- c_flags.final = true @@ -997,7 +1069,7 @@ do -- more or less copied from mtx-plain.lua: else print("mktexlsr silent run") -- we use a basic print end - os.remove("temp.log") + removefile("temp.log") else report("running mktexlsr") os.execute("mktexlsr") @@ -1005,7 +1077,7 @@ do -- more or less copied from mtx-plain.lua: end local function engine(texengine,texformat) - local command = string.format('%s --ini --etex --8bit %s \\dump',texengine,file.addsuffix(texformat,"mkii")) + local command = string.format('%s --ini --etex --8bit %s \\dump',texengine,fileaddsuffix(texformat,"mkii")) if environment.arguments.silent then statistics.starttiming() local command = format("%s > temp.log",command) @@ -1016,7 +1088,7 @@ do -- more or less copied from mtx-plain.lua: else print(format("%s silent make > format %q made in %.3f seconds",texengine,texformat,runtime)) -- we use a basic print end - os.remove("temp.log") + removefile("temp.log") else report("running command: %s",command) os.execute(command) @@ -1080,7 +1152,7 @@ do -- more or less copied from mtx-plain.lua: for k, v in next, environment.arguments do t[#t+1] = string.format("--mtx:%s=%s",k,v) end - execute('%s --fmt=%s %s "%s"',texengine,file.removesuffix(texformat),table.concat(t," "),filename) + execute('%s --fmt=%s %s "%s"',texengine,removesuffix(texformat),table.concat(t," "),filename) end make_mkii_format = function(name,engine) @@ -1225,67 +1297,6 @@ function scripts.context.version() end end --- purging files (we should have an mkii and mkiv variants) - -local generic_files = { - "texexec.tex", "texexec.tui", "texexec.tuo", - "texexec.tuc", "texexec.tua", - "texexec.ps", "texexec.pdf", "texexec.dvi", - "cont-opt.tex", "cont-opt.bak" -} - -local obsolete_results = { - "dvi", -} - -local temporary_runfiles = { - "tui", -- mkii two pass file - "tua", -- mkiv obsolete - "tup", "ted", "tes", -- texexec - "top", -- mkii options file - "log", -- tex log file - "tmp", -- mkii buffer file - "run", -- mkii stub - "bck", -- backup (obsolete) - "rlg", -- resource log - "ctl", -- - "mpt", "mpx", "mpd", "mpo", "mpb", -- metafun - "prep", -- context preprocessed - "pgf", -- tikz - "aux", "blg", -- bibtex -} - -local temporary_suffixes = { - "prep", -- context preprocessed -} -local synctex_runfiles = { - "synctex", "synctex.gz", -- synctex -} - -local persistent_runfiles = { - "tuo", -- mkii two pass file - "tub", -- mkii buffer file - "top", -- mkii options file - "tuc", -- mkiv two pass file - "bbl", -- bibtex -} - -local special_runfiles = { - "%-mpgraph", "%-mprun", "%-temp%-" -} - -local function purge_file(dfile,cfile) - if cfile and validfile(cfile) then - if removefile(dfile) then - return filebasename(dfile) - end - elseif dfile then - if removefile(dfile) then - return filebasename(dfile) - end - end -end - function scripts.context.purge_job(jobname,all,mkiitoo,fulljobname) if jobname and jobname ~= "" then jobname = filebasename(jobname) |