On 9/21/2018 12:05 PM, luigi scarso wrote:


On Fri, Sep 21, 2018 at 11:06 AM Taco Hoekwater <t...@elvenkind.com <mailto:t...@elvenkind.com>> wrote:

    Hi,

     > On 21 Sep 2018, at 10:59, luigi scarso <luigi.sca...@gmail.com
    <mailto:luigi.sca...@gmail.com>> wrote:
     >
     >
     > % start demo
     > \enabledirectives[system.callbacks.permitoverloads]
     > % previous line allows redefinition of ‘wrapup_run’
     > iirc ,
     > this should be avoided ….

    Sure, but I find wrapup_run extremely useful, and I know of no other
    way to use it.


sure but the idea of modifying the context state (broadly speaking) before that context says that the state is consistent
(ie the run is  finished, in this case) is , how to say.. hm hm.
Maybe signalling with an asyn msg that has nothing todo with the context state (just to say "Hey, context here: I am finishing the run" to somebofy else) , but usually one wants  also to check the starts and the end of the run as process, ie just before the run starts and just after the run ended.
This case seems safe but I have already dubious on \
$ lua -e ' os.execute("ls \c*") '
lua: (command line):1: invalid escape sequence near '\c'
while
$ lua -e ' os.execute([[ls \c*]])'
is ok
Also,  I run context foo.tex and at the end  of the runs I found foo.pdf (expected) and doc-<idcode>.pdf ("hm .. where does it come from ? I dont remember ...I have to look into the source" )
so two times the space --- and the copy is done at each run, iirc.


But it's just to complete the picture:  once one  knows the limits, it's a useful callback.
that callback is really the last ... files have been closed then

here is a (future) safe rename variant (assuming \MyID is defined):

    luatex.wrapup(function()
        local oldname = file.addsuffix(environment.jobname,"pdf")
        local newname = file.addsuffix("doc-\MyId","pdf")
        if lfs.isfile(newname) then
            logs.reporter("system","removing %a",newname)
            os.remove(newname)
        end
        if not lfs.isfile(newname) then
            logs.reporter("system","renaming %a to %a",oldname,newname)
            os.rename(oldname,newname)
        end
        if not lfs.isfile(newname) then
            logs.reporter("system","error in renaming")
        end
    end)



-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to