Trailing-Edge
-
PDP-10 Archives
-
mit_emacs_170_teco_1220
-
emacs/latex.tec
There are no other files named latex.tec in the archive.
!* -*-TECO-*- *!
!~Filename~:! !LATEX file!
LATEX
!LATEX CHECK:! !& Check for matching LaTeX delimiters !
!* Q0 = starting pt. !
!* Q1 = mode: 0 = { !
!* 1 = \begin !
!* 2 = $ !
!* 3 = $$ !
!* 4 = \( !
!* 5 = \[ !
!* -1 = initial value !
!* Q2 = location of current left delimiter. !
!* Q3 = environment name if Q1 = 5 !
!* !
.U0 !* Q0 := ptr !
."N !* IF ptr /= 0 !
-1C !* THEN move ptr one to left; type warning !
FT STARTING_IN_MIDDLE_OF_BUFFER
' !* FI !
-1U1 !* Initialize Q1 !
< !loop! !* BEGIN LOOP !
:S\{\}\$\\(\\)\\[\\]\begin\end;
!* Find next delimiter, or exit. !
-1C !* ptr := start of delimiter. !
1A-{"E !* IF current delim = { !
[1 [2 [3 !* THEN push stack. !
0U1 .U2 !* set mode and curr. delim. !
Oloop' !* GOTO loop !
!* FI !
1A-n"E !* IF current delim = \begin !
2A-{"E !* THEN IF followed by { !
[1 [2 [3 !* THEN push level !
.-5U2 !* Q2 := start of \begin !
.+1U4 :S}"E FT
MISSING_} Q2J FS^R_THROW'
-1C Q4,.X3
!* Q3 := environment name !
1U1 !* Q1 := 1 !
' !* FI !
Oloop !* GOTO loop !
' !* FI !
Q1-1"G !* IF in math mode !
-1U4 !* THEN Q4 := -1 !
1A-$"E !* IF current delim = $ !
2A-$"E !* THEN IF next char = $ !
3U4 1C !* THEN Q4 := 3 ; advance ptr 1 pos. !
'"# 2U4 !* ELSE Q4 := 2 !
' !* FI !
'"# 1A-]"E 5U4' !* ELSE IF current delim = ] THEN Q4 := 5 FI !
1A-)"E 4U4' !* IF current delim = ] THEN Q4 := 4 FI !
' !* FI !
Q4-Q1"E !* IF Q4 = curr mode !
]3 ]2 ]1 Oloop'!* THEN pop level ; goto LOOP FI !
Oerror !* GOTO error !
' !* FI !
1A-}"E !* IF current delim = } !
Q1"E !* THEN IF mode = { !
]3 ]2 ]1 !* THEN pop level !
Oloop !* GOTO loop !
'"# Oerror !* ELSE GOTO error !
'' !* FI FI !
1A-$"E !* IF current delim = $ !
[1 [2 [3 .U2 !* THEN push level ; Q2 := ptr !
2A-$"E !* IF next char = $ !
3U1 1C !* THEN Q1 := 3 ; move ptr right one pos. !
'"# 2U1 !* ELSE Q1 := 2 !
' !* FI !
Oloop !* GOTO loop !
' !* FI !
1A-d"E !* IF \end !
2A-{"E !* IF followed by { !
Q1-1"N !* THEN IF mode /= 1 !
Oerror !* THEN GOTO error !
'"# !* ELSE IF Q3 = argument !
.+1U4 :S}"E FT
MISSING_} Q4J FS^R_THROW'
.-1U5 Q4J :S3"N
Q5-."E
]3 ]2 ]1 !* THEN pop level !
Oloop !* GOTO loop !
''' !* FI FI !
!* error !
Q4,Q5X4
FT \begin3}_ENDED_BY_\end4} FS^R_THROW
'"# Oloop !* ELSE GOTO loop !
'' !* FI FI !
1A-["E !* IF current delimiter = \[ !
[1 [2 [3 .U2 5U1 !* THEN push level and set Q1, Q2 !
Oloop ' !* GOTO loop FI !
1A-("E !* IF current delimiter = \( !
[1 [2 [3 .U2 4U1 !* THEN push level and set Q1, Q2 !
Oloop ' !* GOTO loop FI !
Oerror !* Delimiter = $ \) or \] outside math mode. !
> !* ENDLOOP !
Q1+1"G Q2J !* IF not at initial level THEN error !
FT UNMATCHED_DELIMITER FS^R_THROW
'"# Q0J !* ELSE ok. FI !
FT ALL_DELIMITERS_PROPERLY_MATCHED Oend'
!error!
Q1"L !* IF mode = initial !
!* THEN unmatched terminator error !
FT UNMATCHED_TERMINATOR
'"# Q1-1"G !* ELSE IF math mode !
Q4"G !* THEN IF Q4 > 0 !
!* THEN wrong math mode closing !
FT WRONG_MATH_MODE_CLOSING FS ^R_THROW
'"# 1A-["E !* ELSE IF curr delim = \[ !
!* THEN \[ in math mode error FI !
FT \[_IN_MATH_MODE FS ^R_THROW'
1A-("E !* IF curr delim = \( !
!* THEN \( in math mode error FI !
FT \(_IN_MATH_MODE FS ^R_THROW'
'' !* FI FI !
Q2 J !* ptr := Q2 !
FT IMPROPERLY_MATCHED_BEGINNING
' !* FI !
FS^R_THROW
!end!
!COLOR:! !& Insert Color-list Arguments for SLiTeX environments.
Argument is list of colors, separated by commas. !
!* BJ M(M.M LATEX_CHECK) Start by calling LATEX CHECK !
!* Q9 := argument for search command for colors !
ZJ .U0 I Q0J
Q0-Z"E FT YOU_FORGOT_TO_TYPE_ARGUMENT_(COLORS,_SEPARATED_BY_COMMAS)
FS^R_THROW'
<i\ :s,; -1d i> Q0J .,ZX9 .,ZK
!* Q0 = count of slides and overlays !
!* Q1 = beginning of argument location for slide or overlay !
!* Q2 = end of current slide or overlay !
!* Q3,Z = list of colors for current slide. !
!* Q4 = current pointer !
!* Q5 = current color outside of slides !
BJ 0U0 0,0X5 !* Initialize ptr, Q0 and Q5 !
< .U4 !* BEGIN LOOP find next slide or overlay or EXIT !
:S\begin{slide}\begin{overlay};
Q0+1U0 !* Increment Q0 !
.U1 !* Q1 := ptr !
1A-{"E !* IF followed by { !
S} Q1,.K ' !* THEN delete argument FI !
!* Set Q2 !
S\end{slide}\end{overlay} .U2
ZU3 Q4J !* Initialize Q3 and ptr !
< !* BEGIN LOOP !
:S9; !* find next color or EXIT if none !
.U6 -s\ !* Q6 := next color !
.+1,Q6X6 !* !
Q1-."G !* IF color before current slide !
:I56 !* THEN Q5 := Q6 !
'"# Q2-."G !* ELSE IF color in current slide !
.U7 !* THEN Q7 := ptr !
Q3J :S6"E !* IF color not in Q3,Z !
ZJ G6 I, !* THEN add `color,` at Z !
Q7J !* restore ptr !
' !* FI !
'"# 1; !* ELSE exit !
'' !* FI FI !
1c !* advance ptr !
> !* END LOOP !
Q3J FQ5"N :S5"E !* IF Q5 nonempty and color Q5 not in Q3,Z !
ZJ G5 I,'' !* THEN insert it at end FI !
Q3-Z"N ZJ -1D' !* IF Q3,Z nonempty THEN delete comma FI !
Q3,ZX7 Q3,ZK !* Q7 := color list ; delete Q3,Z !
Q1J i{ G7 i} !* Insert color list as argument !
Q2J !* ptr := Q2 !
> !* END LOOP !
BJ FT NUMBER_OF_SLIDES_&_OVERLAYS_=_ Q0=
!STYLE COMPRESS:! !& Converts .DOC file into .STY file. !
[1 [2 [3
bj (FSMODIFIED)"N !* IF buffer modified !
M(M.M^R_Save_File)' !* THEN save it FI !
<:s%; -1c 1k> !* !
bj <:s__; -2c 1d> !* Delete comments. !
bj <.-z"E 1;' .u1 !* Break long lines: !
:l .u2 !* Q1,Q2 := beg,end of line. !
q2-q1-79"G !* IF Q2-Q1 > 79 !
q1j s_ !* THEN find first space in line!
.-q1-79"G q1j !* IF > 79 chars away !
FTType_space,_break_line,_hit_Ctl-Meta-Z !* THEN user breaks !
'"# .U3 <:S ; .-Q1-79"G !* ELSE Find best place !
Q3J 1;' .U3> !* to break line. !
-1d 13I 10I !* Add CR LF. !
' !* FI !
'"# 1l !* ELSE go to next line !
' > !* FI !
bj <:s
_; -1d> !* Delete blanks at start of line. !
bj <:s
; -4c 2d> !* Delete extra CR LF's !
bj M(M.M LATEX_CHECK) !* Check Resulting File. !
M(M.M WRITE_FILE).STY !* Write it out. !
1
!LINE COMPRESS:! !& Finds lines > 79 chars long and lets you fix them. !
[1 [2 [3
bj <.-z"E 1;' .u1 !* Break long lines: !
:l .u2 !* Q1,Q2 := beg,end of line. !
q2-q1-79"G !* IF Q2-Q1 > 79 !
!* THEN type message. !
FTType_space,_break_line,_hit_Ctl-Meta-Z '
' 1l > !* FI GOTO next line !
bj
1
!INDEX:! !& Processes .IDX file (in buffer) created by \makeindex.
Makes permutations of multiple word entries, from 'on the bar'
creating additioal entries 'bar, on the' and 'the bar, on'.
A \noindex{the} appearing in the buffer will suppress the former.
All lines with '\noindex' in them are deleted.!
[1 [2 [3 [4 [5 [6 [7 [8 [9 [A
BJ :I9 !* Q9 := list of \noindex arguments, surrounded !
<:S\noindex{; !* by ^A characters. !
.U1 S} -1C I
Q1,.@X9 >
BJ !* Delete every line containing '\noindex' !
<:S\noindex; 0L 1K>
BJ G9 13I 10I .U9 !* 0,Q9 := list of \noindex arguments, !
!* surrounded by ^A characters. !
Q9J
<:S\indexentry{; !* FOR EVERY \indexentry command: !
.U1 :L -2S} .U2 !* Q1,Q2 := its argument !
1L .U3 !* Q3 := beginning of next line !
Q1U4 !* Q4 := Q1 !
<Q4J Q4,Q2:FB_; !* FOR EVERY space in argument: !
-1C .U5 !* Q4,Q5 := word preceding space !
Q1,Q5X6 !* Q6 := first part of argument !
Q5+1,Q2X7 !* Q7 := second part of argument !
Q1,Q2X8 !* Q8 := whole argument !
Q1,Q2K 0L 1XA Q1J G8 !* GA := line without argument !
Q3J GA !* insert GA at Q3 !
-1L S\indexentry{ !* insert reversed argument in new line !
.UA !* with ~^A instead of comma !
G7 I~_ G6 !* GA := beginning of argument !
1L .U3 !* Q3 := beginning of next line !
QAJ S~_ !* Q6 := first word of created entry !
0A-"E-1C'
QA,.-1X6
0,Q9:FB6"L !* IF Q6 a \noindex word: !
Q3J -1L 1K .U3 !* THEN kill line and reset Q3 !
' !* !
Q5+1U4 !* Q4 := Q5+1 !
> !* !
Q3J !* . := beginning of next line !
>
0,Q9K !* Delete 0,Q9 !
BJ
<:S\indexentry{; !* FOR EVERY \indexentry command: !
1A-\"E !* IF first character = \ !
1D !* THEN delete and !
:L -S{ I|\ !* mark entry with |\^A !
'>
BJ
<:S\indexentry{; !* FOR EVERY \indexentry command: !
1A-91"L 1A-64"G !* IF first character uppercase !
1AU1 1D Q1+32I !* THEN change to lowercase !
:L -S{ I|* !* mark entry with |*^A !
''>
BJ
<:S\indexentry{; .U4 !* FOR EVERY \indexentry command: !
:L -s{ .+1U1 S} .-1U2 !* Q1,Q2 := page number !
Q2-Q1U3 !* Q3 := number of digits !
!* Q4 := beginning of argument !
Q1J -S} .-Q4-20"L !* Pad argument to right with ^@s to make at !
20-.+Q4<I >' !* least 20 characters long. !
Q1J !* . := Q1 !
1A-9"G !* IF page number not numeric !
I
' !* THEN add 12 ^@ characters !
12-Q3<I > !* Pad number on left with ^@ characters !
>
S\indexentry{$ :L 1L !* Sort Entries !
BJ <:S ; -1D> !* Delete ^@ characters !
BJ
<:S|*; !* Restore uppercase letters. !
-3D 0L :S\indexentry{
1AU1 1D Q1-32I
:L -S}{ I* !* Put marker into argument !
>
BJ
<:S|\; !* Restore backslashes letters. !
-3D 0L :S\indexentry{
i\
>
BJ
<:S~; !* Put commas in place of ~^As. !
-2D i,
>
BJ
<:S\indexentry{; !* FOR EVERY \indexentry command: !
.U1 :L -2S} .U2 !* Q1,Q2 := Argument !
S{ .U3 S} .-1U4 !* Q3,Q4 := Page number !
1L .U5 !* Q5 := Beginning of next entry !
<Q5J :S\indexentry{; !* FOR EACH SUCCEEDING ENTRY !
.U6 :L -2S} Q6,.X6 !* Q6 := its argument !
Q1,Q2:FB6; !* IF Q6 /= preceding entrys argument: !
.-Q2"N 1;' !* THEN exit FOR loop. !
Q5J :L -S} .U6 !* Q6 := entrys page number. !
-S{ .+1,Q6X6 !* !
0L 1K !* Delete entry !
Q3,Q4:FB6"E !* IF number not in previous entry !
Q4J I,_ G6 .U4 !* THEN add it, update Q4 and Q5 !
1L .U5 !* !
'
>
Q5J
>
BJ
<:S*; -2D> !* Delete uppercase markers. !
]A ]9 ]8 ]7 ]6 ]5 ]4 ]3 ]2 ]1
!ITEM:! !& Turns entries made by INDEX into \item's and \subitem's.
Successive entries with same first word are turned into \item plus
\subitem.!
[1 [2 [3 [4 [5 [6
BJ
<:S\indexentry{; !* FOR EVERY \indexentry command: !
.U1 0L .,Q1K !* Delete the '\indexentry{' . !
.U1 S_,} -1C .U2 !* Q1,Q2 := first word of entry. !
1L 0U9 !* Q9 := 0 [switch set if match found] !
<:S\indexentry{; !* FOR following EVERY \indexentry commands: !
.U3 S_,} -1C .U4 !* Q3,Q4 := first word of entry. !
Q3,Q4X5 Q1,Q2:FB5; !* Exit FOR loop if words not the same. !
.-Q2"N 1;' !* !
1U9 !* Q9 := 1 [switch indicates match found. !
Q3J 0L .,Q4K !* Delete the \indexentry and first word !
1A-,"E 1D' !* Delete comma if it follows. !
I__\subitem_ !* Insert \subitem and fix rest of entry !
:L -S} 1D -S}{
2D I,_
>
Q9"N !* IF match was found !
0U9 !* Q9 := 0 !
Q2J 1A-}"N !* IF not a single-word item !
1U9 !* THEN Q9 := 1 !
1A-,"E 1D' !* Delete comma if it follows. !
13I 10I Q1J I\item_ !* Insert \item before first word !
1L I__\subitem_ !* Make rest a separate \subitem !
:L -S} 1D -S}{
2D I,_
''
Q9"E !* IF Q9 = 0 !
Q1J I\item_ !* THEN make an \item !
:L -S} 1D -S}{
2D I,_
'
>
]6 ]5 ]4 ]3 ]2 ]1