-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheval4tex.tex
92 lines (75 loc) · 2.39 KB
/
eval4tex.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
% eval4tex.tex
% Dorai Sitaram
% Last change 2017-01-16
\let\maybeendinput\relax
\ifx\shipout\UnDeFiNeD
\let\maybeendinput\endinput
\fi
\maybeendinput
\newcount\evalQauxfilecount
\evalQauxfilecount=0
{\catcode`\^^M=12 %
\gdef\evalfortexQsetup{%
\expandafter\csname newwrite\endcsname \evalfortexQport %
%
\immediate\openout\evalfortexQport \jobname-Z-E-D.lisp %
\newlinechar=`\^^M%
\immediate\write\evalfortexQport{
(defmacro define (lhs &rest body)
(if (consp lhs) `(defun ,(car lhs) ,(cdr lhs) ,@body)
`(defvar ,lhs ,@body)))
(defun current-output-port (&optional p)
(if p (setq *standard-output* p) *standard-output*))
(defun file-exists? (f) (probe-file f))
(defun open-output-file (f)
(open f :direction :output :if-exists :supersede))
(defun close-output-port (p) (close p))
(defun display (x) (princ x))
(defun newline () (terpri))
(defun integer->char (n) (code-char n))
}%
\immediate\closeout\evalfortexQport %
%
\immediate\openout\evalfortexQport \jobname-Z-E.lisp %
%\newlinechar=`\^^M%
\immediate\write\evalfortexQport{
(if (not 'nil)
(eval '(load "\jobname-Z-E-D.lisp"))
(not 0))
(define *eval4tex-current-output-port* (current-output-port))
(define (eval4tex-preamble f)
(if (file-exists? f) (delete-file f) 0)
(current-output-port (open-output-file f)))
(define (eval4tex-postamble)
(display (integer->char 92))
(display "relax") (newline)
(close-output-port (current-output-port))
(current-output-port *eval4tex-current-output-port*))
}%
\newlinechar=-1 %
}%
}
\def\eval{\evalQi d} %display the output
\def\evalq{\evalQi q} %don't display the output
\def\evalQi#1{\begingroup
\ifx\evalfortexQport\UNDEFINED \evalfortexQsetup\fi
\global\advance\evalQauxfilecount by 1
\edef\evalQauxfile{\jobname-Z-E-\the\evalQauxfilecount}%
\immediate\write\evalfortexQport
{(eval4tex-preamble "\evalQauxfile.tex")}%
% should the following \input be in a group?
\ifx#1d{\immediate\openin0=\evalQauxfile.tex
\ifeof0 \immediate\closein0
\else \immediate\closein0 \input \evalQauxfile.tex \fi}\fi
\def\do##1{\catcode`##1=12 }\dospecials
\catcode`\{=1 \catcode`\}=2
\catcode`\|=0
\catcode`\^^M=12
\newlinechar=`\^^M%
\evalQii}
\def\evalQii#1{%
\immediate\write\evalfortexQport{#1}%
\immediate\write\evalfortexQport{(eval4tex-postamble)}%
\newlinechar=-1 %
\endgroup}
% end of file