;batconfg.lsp ;Configures SLaTeX batfile/shellscript (CL version) ;(c) Dorai Sitaram, Rice U., 1991, 1994 (princ "Beginning configuring command script -- wait... ") (defvar *dialect* 'cl) (defvar *op-sys* 'forward) (defvar scheme-pathname 'forward) (defvar slatex-pathname 'forward) (defvar texinputs 'forward) (defvar texinputs-list 'forward) (defvar accepts-echo 'forward) (defvar accepts-cmdline-file 'forward) (defvar accepts-initfile 'forward) (defvar system-procedure 'forward) (with-open-file (inp "config.dat" :direction :input) (read inp) ;ignore dialect info (setq *op-sys* (read inp)) (setq scheme-pathname (read inp)) (setq slatex-pathname (read inp)) (setq texinputs (read inp)) (setq texinputs-list (read inp)) (setq accepts-echo (read inp)) (setq accepts-cmdline-file (read inp)) (setq accepts-initfile (read inp)) (setq system-procedure (read inp)) ) (if (not (member *op-sys* '(os2 os2fat dos unix))) (setq *op-sys* 'unix)) (defvar bat-file 'forward) (case *op-sys* ((os2 os2fat) (setq bat-file "slatex.cmd")) ((dos) (setq bat-file "slatex.bat")) ((unix) (setq bat-file "slatex"))) (if (probe-file bat-file) (delete-file bat-file)) (defvar op 'forward) (setq op (open bat-file :direction :output)) (if (member *op-sys* '(os2 os2fat dos)) (princ "@echo off " op)) (if (eq *op-sys* 'unix) (cond (accepts-echo (princ "echo '(load " op) (prin1 slatex-pathname op) (princ ") (setq SLaTeX.*texinputs* \"'$TEXINPUTS'\") (setq SLaTeX.*texinputs-list* `" op) (prin1 texinputs-list op) (princ ") (SLaTeX.process-main-tex-file \"'$1'\")' | " op) (princ scheme-pathname op) (terpri op)) (accepts-cmdline-file (princ "echo '(load " op) (prin1 slatex-pathname op) (princ ")' > slatex.jnk echo '(setq SLaTeX.*texinputs* \"'$TEXINPUTS'\")' >> slatex.jnk echo '(setq SLaTeX.*texinputs-list* `" op) (prin1 texinputs-list op) (princ ")' >> slatex.jnk echo '(SLaTeX.process-main-tex-file \"'$1'\")' >> slatex.jnk echo '(SLaTeX.exit-scheme)' >> slatex.jnk " op) (princ scheme-pathname op) (princ " slatex.jnk rm slatex.jnk " op)) (accepts-initfile (princ "echo '(load " op) (prin1 slatex-pathname op) (princ ") (setq SLaTeX.*texinputs* \"'$TEXINPUTS'\") (setq SLaTeX.*texinputs-list* `" op) (prin1 texinputs-list op) (princ ") (SLaTeX.process-main-tex-file \"'$1'\") (SLaTeX.exit-scheme)' >> ") (princ accepts-initfile op) (terpri op) (princ scheme-pathname op) (terpri op) (princ "rm " op) (princ accepts-initfile op) (terpri op)) (:else (princ "Your Scheme/system interface isn't very cooperative -- use callsla.scm ")))) (if (not (eq *op-sys* 'unix)) (progn (cond (accepts-cmdline-file (princ "echo (load " op) (prin1 slatex-pathname op) (princ ") > slatex.jnk echo (setq SLaTeX.*texinputs* " op) (prin1 texinputs op) (princ ") >> slatex.jnk echo (setq SLaTeX.*texinputs-list* `" op) (prin1 texinputs-list op) (princ ") >> slatex.jnk echo (SLaTeX.process-main-tex-file \"%1\") >> slatex.jnk echo (SLaTeX.exit-scheme) >> slatex.jnk call " op) (princ scheme-pathname op) (princ " slatex.jnk del slatex.jnk " op)) ((or accepts-echo accepts-initfile) (if accepts-echo (setq accepts-initfile "slatex.jnk")) (princ "echo '(load " op) (prin1 slatex-pathname op) (princ ") (setq SLaTeX.*texinputs* " op) (prin1 texinputs op) (princ ") (setq SLaTeX.*texinputs-list* `" op) (prin1 texinputs-list op) (princ ") (SLaTeX.process-main-tex-file \"%1\") (SLaTeX.exit-scheme)' >> " op) (princ accepts-initfile op) (terpri op) (if accepts-echo (princ "echo (load \"slatex.jnk\") | " op)) (princ scheme-pathname op) (terpri op) (princ "del " op) (princ accepts-initfile op) (terpri op))))) (if (eq *op-sys* 'unix) (progn (princ "if test -f pltexchk.jnk then tex $1; rm pltexchk.jnk else latex $1 fi" op)) (progn (princ "rem attrib +h " op) (princ (if (eq *op-sys* 'os2) "." "x") op) (princ "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 op) (if (member *dialect* '(chez cscheme pcsge scm)) (if (probe-file "callsla.scm") (delete-file "callsla.scm"))) (with-open-file (op "callsla.scm" :direction :output) (princ "(let ((slatex-not-loaded? t)) (defun call-slatex (texf) (if slatex-not-loaded? (progn (princ \"Loading SLaTeX...\") (load " op) (prin1 slatex-pathname op) (princ " ) (princ 'done) (terpri) (setq SLaTeX.*texinputs* " op) (prin1 texinputs op) (princ " ) (setq slatex-not-loaded? #f))) (SLaTeX.process-main-tex-file texf) (terpri) " op) (if system-procedure (princ "(system (concatenate 'string (if SLaTeX.*latex?* \"latex \" \"tex \") texf))" op) (princ "(progn (princ \"Call (la)tex on \") (princ texf) (terpri))" op)) (princ "t)))" op)) (princ "Finished configuring batfile/shellscript") (terpri) (if (eq *op-sys* 'unix) (progn (princ "Type (chmod +x slatex) on Unix command line") (terpri)))