Redefining a letter to itself
An \expandafter
before \active
tokenizes the following \def
without the changed category code of e
:
{
\catcode`e=\expandafter\active
\def e{\char`e}
SomeText
}
Another trick works via \lowercase
. The definition is done with the active ~
that is changed via \lowercase
to e
. Afterwords the category code is changed.
{
\begingroup
\lccode`~=`e %
\lowercase{\endgroup
\def~%
}{\char`e}%
\catcode`e=\active
SomeText
}
\documentclass{article}
\begin{document}
% Now I can't use e, so I have to use something else instead.
% I tried ^^65, but it doesn't work (65 is ASCII hex value for e)
{\let\z\def
\catcode`e=\active
\ze{\char`\e}
SomeText
}
or
{\let\z\edef
\catcode`e=\active
\ze{\stringe}
SomeText
}
\end{document}
Exploit a benign effect of the “missing space syndrome“:
{\catcode`e=13\def e{-\char`\e-}Test}Test\bye
With an abstraction:
\def\defactive#1#2{%
\begingroup
\lccode`~=`#1\lowercase{\endgroup\def~}{#2}%
\catcode`#1=\active
}
{\defactive{e}{-e-}Test}Test
\bye