summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-context.lua39
-rw-r--r--scripts/context/lua/mtx-context.xml3
2 files changed, 32 insertions, 10 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index d419dd25e..f5971e15c 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -361,20 +361,29 @@ local function multipass_changed(oldhash, newhash)
return false
end
-local f_tempfile = formatters["%s-%s-%02d.tmp"]
+local f_tempfile_i = formatters["%s-%s-%02d.tmp"]
+local f_tempfile_s = formatters["%s-%s-keep.%s"]
local function backup(jobname,run,kind,filename)
- if run == 1 then
- for i=1,10 do
- local tmpname = f_tempfile(jobname,kind,i)
- if validfile(tmpname) then
- removefile(tmpname)
- report("removing %a",tmpname)
+ if run then
+ if run == 1 then
+ for i=1,10 do
+ local tmpname = f_tempfile_i(jobname,kind,i)
+ if validfile(tmpname) then
+ removefile(tmpname)
+ report("removing %a",tmpname)
+ end
end
end
- end
- if validfile(filename) then
- local tmpname = f_tempfile(jobname,kind,run or 1)
+ if validfile(filename) then
+ local tmpname = f_tempfile(jobname,kind,run or 1)
+ report("copying %a into %a",filename,tmpname)
+ file.copy(filename,tmpname)
+ else
+ report("no file %a, nothing kept",filename)
+ end
+ elseif validfile(filename) then
+ local tmpname = f_tempfile_s(jobname,kind,kind)
report("copying %a into %a",filename,tmpname)
file.copy(filename,tmpname)
else
@@ -395,6 +404,14 @@ local function multipass_copyluafile(jobname,run)
end
end
+local function multipass_copypdffile(jobname,run)
+ local pdfname = jobname..".pdf"
+ if validfile(pdfname) then
+ backup(jobname,false,"pdf",pdfname)
+ report()
+ end
+end
+
local function multipass_copylogfile(jobname,run)
local logname = jobname..".log"
if validfile(logname) then
@@ -673,6 +690,7 @@ function scripts.context.run(ctxdata,filename)
local a_texformat = getargument("texformat")
local a_keeptuc = getargument("keeptuc")
local a_keeplog = getargument("keeplog")
+ local a_keeppdf = getargument("keeppdf")
local a_export = getargument("export")
local a_nodates = getargument("nodates")
local a_trailerid = getargument("trailerid")
@@ -890,6 +908,7 @@ function scripts.context.run(ctxdata,filename)
elseif returncode == 0 then
multipass_copyluafile(jobname,a_keeptuc and currentrun)
multipass_copylogfile(jobname,a_keeplog and currentrun)
+ multipass_copypdffile(jobname,a_keeppdf and currentrun)
if not multipass_forcedruns then
newhash = multipass_hashfiles(jobname)
if multipass_changed(oldhash,newhash) then
diff --git a/scripts/context/lua/mtx-context.xml b/scripts/context/lua/mtx-context.xml
index 98a75244b..d4e0d33c5 100644
--- a/scripts/context/lua/mtx-context.xml
+++ b/scripts/context/lua/mtx-context.xml
@@ -202,6 +202,9 @@
<flag name="keeptuc">
<short>keep previous tuc files (jobname-tuc-[run].tmp)</short>
</flag>
+ <flag name="keeppdf">
+ <short>keep previous pdf files (jobname-pdf-keep.tmp)</short>
+ </flag>
<flag name="keeplog">
<short>keep previous log files (jobname-log-[run].tmp)</short>
</flag>