remove empty dir
[ghc-hetmet.git] / docs / storage-mgt / code.sty
1 \r
2 % I have enclosed code.sty, which achieves 99% of what you want without\r
3 % the need for a separate preprocessor. At the start of your document\r
4 % you write "\makeatactive". From then on, inline code is written as @\x\r
5 % -> x_1 & y@. The only difference with what you are used to, is that\r
6 % instead of\r
7\r
8 % @\r
9 %   foo :: Int -> Int\r
10 %   foo = \n -> n+1\r
11 % @\r
12\r
13 % you have to write\r
14\r
15 % \begin{code}\r
16 %   foo :: Int -> Int\r
17 %   foo = \n -> n+1\r
18 % \end{code}\r
19\r
20 % and that you cannot use @ in \section{} and \caption{}. For the paper that occured twice, in which case I had to replace @...@ b y \texttt{...}.\r
21\r
22\r
23 % code.sty  --- nice verbatim mode for code\r
24 \r
25 \def\icode{%\r
26     \relax\ifmmode\hbox\else\leavevmode\null\fi\r
27     \bgroup\r
28     %\begingroup\r
29     \@noligs\r
30     \verbatim@font\r
31     \verb@eol@error\r
32     \let\do\@makeother \dospecials\r
33     \@vobeyspaces\r
34     \frenchspacing\r
35     \@icode}\r
36 \def\@icode#1{%\r
37     \catcode`#1\active\r
38     \lccode`\~`#1%\r
39     \lowercase{\let~\icode@egroup}}\r
40 \def\icode@egroup{%\r
41     %\endgroup}\r
42     \egroup}\r
43 \r
44 % The \makeatactive command:\r
45 % makes @ active, in such a way that @...@ behaves as \icode@...@:\r
46 {\r
47 \catcode`@=\active\r
48 \gdef\makeatactive{\r
49      \catcode`@=\active \def@{\icode@}\r
50      % Since @ becomes active, it has to be taken care of in verbatim-modes:\r
51      \let\olddospecials\dospecials \def\dospecials{\do\@\olddospecials}}\r
52 }\r
53 % \gdef\makeatother{\g@remfrom@specials{\@}\@makeother\@}\r
54 \gdef\makeatother{\@makeother\@}\r
55 \r
56 \newcommand\codetabwidth{42pt}\r
57 {\catcode`\^^I=\active%\r
58 \gdef\@vobeytab{\catcode`\^^I\active\let^^I\@xobeytab}}\r
59 \def\@xobeytab{\leavevmode\penalty10000\hskip\codetabwidth}\r
60 \r
61 \begingroup \catcode `|=0 \catcode `[= 1\r
62 \catcode`]=2 \catcode `\{=12 \catcode `\}=12\r
63 \catcode`\\=12 |gdef|@xcode#1\end{code}[#1|end[code]]\r
64 |endgroup\r
65 \def\@code{\trivlist \item\relax\r
66   \if@minipage\else\vskip\parskip\fi\r
67   \leftskip\@totalleftmargin\rightskip\z@skip\r
68   \parindent\z@\parfillskip\@flushglue\parskip\z@skip\r
69   \@@par\r
70   \@tempswafalse\r
71   \def\par{%\r
72     \if@tempswa\r
73       \leavevmode \null \@@par\penalty\interlinepenalty\r
74     \else\r
75       \@tempswatrue\r
76       \ifhmode\@@par\penalty\interlinepenalty\fi\r
77     \fi}%\r
78   \obeylines \verbatim@font \@noligs\r
79   \let\do\@makeother \dospecials\r
80   \everypar \expandafter{\the\everypar \unpenalty}%\r
81 }\r
82 \def\code{\@code \frenchspacing\@vobeytab\@vobeyspaces \@xcode}\r
83 \def\endcode{\if@newlist \leavevmode\fi\endtrivlist}\r