Version 2 of calling pdflatex

Updated 2007-07-06 12:52:59 by dkf

::if 0 {

 @tclkitsh "%~dp0\%~n0.bat" %*
 @goto :EOF
 }

 # pl.bat - helper/shell for pdflatex (TexLive)
 # call pdflatex with specific or with newest file (win-doubleclick)
 # 05.07.2007, MHo
 # if no arg specified, it's assumed that the newest .tex file should be processed

 if {![llength $argv]} {
    set res [list ]
    foreach texfile [glob -nocomplain -- *.tex] {
       lappend res [list $texfile [file mtime $texfile]]
    }
    if {[llength $res]} {
       lappend argv [file rootname [lindex [lindex [lsort -integer -index 1 $res] end] 0]]
       puts "using '$argv'"
    }
 }

 # Trivial wrappers by DKF
 proc pdflatex args {
    eval [list exec -- pdflatex --interaction=nonstopmode] $args
 }
 proc viewPdf filename {
    exec -- $env(comspec) /c $filename &; # att: auto_execok-error with cmd /c
 }

 # to be reorganized later
 # 3 steps to keep tocs and indices etc. accurate - later cond' breaks
 # better use bgExec to catch the output?
 set root [lindex $argv 0]
 puts [pdflatex $root]
 puts [pdflatex $root]
 puts [pdflatex $root]
 viewPdf $root.pdf