\def\LL{<<}
\def\GG{>>}
\def\LLS{[[}
\def\RRS{]]}

% make \hsize in code sufficient for 88 columns
\setbox0=\hbox{\tt m}
\newdimen\codehsize
\codehsize=91\wd0 % 88 columns wasn't enough; I don't know why
\newdimen\codemargin
\codemargin=0pt

\chardef\other=12
\def\setupcode{%
  \chardef\\=`\\
  \chardef\{=`\{
  \chardef\}=`\}
  \catcode`\$=\other
  \catcode`\&=\other
  \catcode`\#=\other
  \catcode`\%=\other
  \catcode`\~=\other
  \catcode`\_=\other
  \catcode`\^=\other
  \obeyspaces\Tt
}
{\catcode`\^^M=\active % make CR an active character
  \gdef\newlines{\catcode`\^^M=\active % make CR an active character
         \def^^M{\par\startline}}%
  \gdef\eatline#1^^M{\relax}%
}
%%% DON'T   \gdef^^M{\par\startline}}% in case ^^M appears in a \write
\def\startline{\noindent\hskip\parindent\ignorespaces}

{\obeyspaces\global\let =\ } % from texbook, p 381
\def\setupmodname{%
  \catcode`\$=3
  \catcode`\&=4
  \catcode`\#=6
  \catcode`\%=14
  \catcode`\~=13
  \catcode`\_=8
  \catcode`\^=7
  \catcode`\ =10
  \catcode`\^^M=5
  \rm}
\def\LA{\begingroup\setupmodname\it$\langle${}}
\def\RA{\/$\rangle$\endgroup}
\def\code{\leavevmode\begingroup\setupcode\newlines}
\def\edoc{\endgroup}

\newbox\equivbox
\setbox\equivbox=\hbox{$\equiv$}
\newbox\plusequivbox
\setbox\plusequivbox=\hbox{$\mathord{+}\mathord{\equiv}$}
% \moddef can't have an argument because there might be \code...\edoc
\def\moddef{\leavevmode\kern-\codemargin\LA}
\def\endmoddef{\RA\unhcopy\equivbox}
\def\plusendmoddef{\RA\unhcopy\plusequivbox}

\def\filename#1{\vfil\eject\mark{#1}}

\def\chunklist{%
\expandafter\errhelp\expandafter{I changed \noexpand\chunklist\space
to \noexpand\nowebchunks.  I'll try to avoid such incompatible changes
in the future.}%
\errmessage{Use \string\nowebchunks\space instead of \chunklist.}}
\def\nowebchunks{\message{<Warning: You need noweave -x to use \string\nowebchunks>}}
\def\nowebindex{\message{<Warning: You need noweave -idx to use \string\nowebindex>}}

% here is support for the new-style (capitalized) font-changing commands
% thanks to Dave Love
\ifx\documentstyle\undefined
  \let\Rm=\rm \let\Tt=\tt	% plain
\else\ifx\selectfont\undefined
  \let\Rm=\rm \let\Tt=\tt	% LaTeX OFSS
\else				% LaTeX NFSS
  \def\Rm{\fontfamily\rmdefault \fontseries\default@series
    \fontshape\default@shape \selectfont}
  \def\Tt{\fontfamily\ttdefault \fontseries\default@series
    \fontshape\default@shape \selectfont}
\fi
\fi
