;batconfg.scm ;Configures SLaTeX batfile/shellscript (Scheme version) ;(c) Dorai Sitaram, Rice U., 1991, 1994 (display "Beginning configuring command script -- wait... ") (define *dialect* 'forward) (define *op-sys* 'forward) (define scheme-pathname 'forward) (define slatex-pathname 'forward) (define texinputs 'forward) (define texinputs-list 'forward) (define accepts-echo 'forward) (define accepts-cmdline-file 'forward) (define accepts-initfile 'forward) (define system-procedure 'forward) (call-with-input-file "config.dat" (lambda (ip) (set! *dialect* (read ip)) (set! *op-sys* (read ip)) (set! scheme-pathname (read ip)) (set! slatex-pathname (read ip)) (set! texinputs (read ip)) (set! texinputs-list (read ip)) (set! accepts-echo (read ip)) (set! accepts-cmdline-file (read ip)) (set! accepts-initfile (read ip)) (set! system-procedure (read ip)) )) (if (not (memq *op-sys* '(os2 os2fat unix dos))) (set! *op-sys* 'unix)) (define bat-file 'forward) (case *op-sys* ((os2 os2bat) (set! bat-file "slatex.cmd")) ((dos) (set! bat-file "slatex.bat")) ((unix) (set! bat-file "slatex"))) (if (memq *dialect* '(chez cscheme scm)) (if (file-exists? bat-file) (delete-file bat-file))) (define op (open-output-file bat-file)) (if (memq *op-sys* '(os2 os2fat dos)) (display "@echo off " op)) (if (eq? *op-sys* 'unix) (cond (accepts-echo (display "echo '(load " op) (write slatex-pathname op) (display ") (set! SLaTeX.*texinputs* \"'$TEXINPUTS'\") (set! SLaTeX.*texinputs-list* `" op) (write texinputs-list op) (display ") (SLaTeX.process-main-tex-file \"'$1'\")' | " op) (display scheme-pathname op) (newline op)) (accepts-cmdline-file (display "echo '(load " op) (write slatex-pathname op) (display ")' > slatex.jnk echo '(set! SLaTeX.*texinputs* \"'$TEXINPUTS'\")' >> slatex.jnk echo '(set! SLaTeX.*texinputs-list* `" op) (write texinputs-list op) (display ")' >> slatex.jnk echo '(SLaTeX.process-main-tex-file \"'$1'\")' >> slatex.jnk echo '(SLaTeX.exit-scheme)' >> slatex.jnk " op) (display scheme-pathname op) (display " slatex.jnk rm slatex.jnk " op)) (accepts-initfile (display "echo '(load " op) (write slatex-pathname op) (display ") (set! SLaTeX.*texinputs* \"'$TEXINPUTS'\") (set! SLaTeX.*texinputs-list* `" op) (write texinputs-list op) (display ") (SLaTeX.process-main-tex-file \"'$1'\") (SLaTeX.exit-scheme)' >> ") (display accepts-initfile op) (newline op) (display scheme-pathname op) (newline op) (display "rm " op) (display accepts-initfile op) (newline op)) (else (display "Your Scheme/system interface isn't very cooperative -- use callsla.scm ")))) (if (not (eq? *op-sys* 'unix)) (begin (cond (accepts-cmdline-file (display "echo (load " op) (write slatex-pathname op) (display ") > slatex.jnk echo (set! SLaTeX.*texinputs* " op) (write texinputs op) (display ") >> slatex.jnk echo (set! SLaTeX.*texinputs-list* `" op) (write texinputs-list op) (display ") >> slatex.jnk echo (SLaTeX.process-main-tex-file \"%1\") >> slatex.jnk echo (SLaTeX.exit-scheme) >> slatex.jnk call " op) (display scheme-pathname op) (display " slatex.jnk del slatex.jnk " op)) ((or accepts-echo accepts-initfile) (if accepts-echo (set! accepts-initfile "slatex.jnk")) (display "echo '(load " op) (write slatex-pathname op) (display ") (set! SLaTeX.*texinputs* " op) (write texinputs op) (display ") (set! SLaTeX.*texinputs-list* `" op) (write texinputs-list op) (display ") (SLaTeX.process-main-tex-file \"%1\") (SLaTeX.exit-scheme)' >> " op) (display accepts-initfile op) (newline op) (if accepts-echo (display "echo (load \"slatex.jnk\") | " op)) (display scheme-pathname op) (newline op) (display "del " op) (display accepts-initfile op) (newline op))))) (if (eq? *op-sys* 'unix) (begin (display "if test -f pltexchk.jnk then tex $1; rm pltexchk.jnk else latex $1 fi" op)) (begin (display "attrib +h " op) (display (if (eq? *op-sys* 'os2) "." "x") op) (display "z*.tex if exist pltexchk.jnk goto one goto two :one call tex %1 del pltexchk.jnk goto end :two call latex %1 :end " op))) (close-output-port op) (if (memq *dialect* '(chez cscheme pcsge scm)) (if (file-exists? "callsla.scm") (delete-file "callsla.scm"))) (call-with-output-file "callsla.scm" (lambda (op) (display "(define call-slatex (let ((slatex-not-loaded? #t)) (lambda (texf) (if slatex-not-loaded? (begin (display \"Loading SLaTeX...\") (load " op) (write slatex-pathname op) (display " ) (display 'done) (newline) (set! SLaTeX.*texinputs* " op) (write texinputs op) (display " ) (set! slatex-not-loaded? #f))) (SLaTeX.process-main-tex-file texf) (newline) " op) (if system-procedure (display "(system (string-append (if SLaTeX.*latex?* \"latex \" \"tex \") texf))" op) (display "(begin (display \"Call (la)tex on \") (display texf) (newline))" op)) (display "#t)))" op))) (display "Finished configuring batfile/shellscript") (newline) (if (eq? *op-sys* 'unix) (begin (display "Type (chmod +x slatex) on Unix command line") (newline)))