summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/misc/unouter.tex
blob: 8b640aaf1f75e897ebb14c6430187825383000ba (plain)
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
% unouter.tex - remove the concept of \outer from plain TeX
% By Eamonn McManus Nov 88.  This file is not copyrighted.

% This macro removes the outerness of the control sequence \csname#1\endcsname
% by copying it to \csname un*#1\endcsname and then defining
% \csname#1\endcsname to be a macro that expands to that.  For example,
% after \unouter{proclaim}, we have: \proclaim=macro:->\un*proclaim .
% and \un*proclaim=\outer macro:->[original definition of \proclaim] .
% It would be nice if we could avoid this extra level, but I know of no way
% of doing that short of writing the \meaning to a file and reading that in
% again (yeuch).
\def\unouter#1{\toks0=\expandafter{\csname un*#1\endcsname}%
	\edef\next{\let\the\toks0=}\expandafter\next\csname#1\endcsname
	\expandafter\edef\csname#1\endcsname{\the\toks0}}

% In the case where the macro has no parameter text, we can unouter it
% directly by putting its expansion into a token list and redefining it
% in terms of that expansion.
\def\simpunouter#1{%
	\toks0=\expandafter\expandafter\expandafter{\csname#1\endcsname}%
	\expandafter\edef\csname#1\endcsname{\the\toks0}}

% ^^L is defined as \outer\par
\let^^L=\par

% Change everything else defined as \outer.
\simpunouter{newcount} \simpunouter{newdimen} \simpunouter{newskip}
\simpunouter{newmuskip} \simpunouter{newbox} \simpunouter{newtoks}
\simpunouter{newread} \simpunouter{newwrite} \simpunouter{newfam}
\simpunouter{+} \simpunouter{bye}
\unouter{newhelp} \unouter{newif} \unouter{beginsection} \unouter{proclaim}

% \unouter no longer needed, and remove the offending primitive!
\let\unouter=\undefined \let\simpunouter=\undefined \let\outer=\relax

\endinput