X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/db6c3279edc260e3e301df1c9b082b374cd002c7..34042b3558b28b85fa7155f7c7cd171239cbbaa3:/doc/sod.sty?ds=sidebyside

diff --git a/doc/sod.sty b/doc/sod.sty
index d77c038..9ff6181 100644
--- a/doc/sod.sty
+++ b/doc/sod.sty
@@ -57,6 +57,15 @@
 %% Listings don't need to be small.
 \let\listingsize\relax
 
+%% Notes for later.
+\def\fixme#1{\leavevmode\marginpar{FIXME}\index{FIXME}[FIXME: #1]}
+
+%% Diagram settings.
+\tikzset{
+  every picture/.style={>=stealth, thick},
+  lit/.style={font=\sffamily}
+}
+
 %% Metavariables are italics without decoration.
 \def\syntleft{\normalfont\itshape}
 \let\syntright\empty
@@ -69,6 +78,7 @@
 }
 \def\ulitleft{\normalfont\codeface}
 \let\ulitright\empty
+\def\lit@i#1#2#3{\ifmmode\leavevmode\hbox\fi{#1{#3\/}#2}}
 
 %% Conditionally enter maths mode.  Can't use \ensuremath here because we
 %% aren't necessarily sure where the maths will actually end.
@@ -136,6 +146,7 @@
 \def\ind{\quad\=\+\kill}
 \def\@progcr{\futurelet\@tempa\@progcr@i}
 {\def\:{\gdef\@progcr@sp}\: {\@progcr}}
+\atdef~{\textasciitilde}
 \def\@progcr@i{%
   \ifx\@tempa\@sptoken\let\next@\@progcr@sp\else
   \if1\ifx\@tempa[1\else
@@ -199,22 +210,31 @@
 \def\nlret{\\\hspace{4em}\returns}
 
 \def\q@{\q@}
-\def\parse@dhd#1{\@ifnextchar[{\parse@dhd@a{#1}}{\parse@dhd@c{#1}}}
-\def\parse@dhd@a#1[#2]{#1{#2}}
-\def\parse@dhd@c#1#2#3{\parse@dhd@cc{#1}{#2}{#3}#3 \q@}
-\def\parse@dhd@cc#1#2#3#4 #5\q@{#1{#4}{#2}{#3}}
+
+%% \parse@dhd{NEXT}{CAT}[NAME]{SYNOPSIS}
+%% call NEXT{CAT}{NAME}{SYNOPSIS}
+%%            #1   #2      #3
+\def\parse@dhd#1#2{%  {NEXT}{CAT}
+  \@ifnextchar[{\parse@dhd@cc{#1}{#2}}{\parse@dhd@cd{#1}{#2}}}
+\def\parse@dhd@cc#1#2[#3]#4{%  {NEXT}{CAT}[NAME]{SYNOPSIS}
+  #1{#2}{#3}{#4}}
+\def\parse@dhd@cd#1#2#3{%  {NEXT}{CAT}{SYNOPSIS}
+  \parse@dhd@ce{#1}{#2}{#3}#3 \q@}
+\def\parse@dhd@ce#1#2#3#4 #5\q@{%
+  % {NEXT}{CAT}{SYNOPSIS}NAME [ARGS...]\q@
+  #1{#2}{#4}{#3}}
 
 \newif\if@dheadfirst
 \def\dhead{\parse@dhd\dhead@}
-\def\dhead@#1#2#3{%
+\def\dhead@#1#2#3{%  {CAT}{NAME}{SYNOPSIS}
   \if@dheadfirst\global\@dheadfirstfalse\else\relax\\[\smallskipamount]\fi%
-  {\let\protect\@empty\def\@uscore{_\@gobble}\message{#2:#1}%
-   \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\label{#2:#1}}\@tempa}%
+  {\let\protect\@empty\def\@uscore{_\@gobble}\message{#1:#2}%
+   \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\label{#1:#2}}\@tempa}%
   {\begingroup\lccode`\~=`\_\lowercase{\endgroup\def~{_}}%
    \protected@edef\@tempa##1{%
      \noexpand\index{%
-       #1@{\noexpand\code{#1}}!%
-       \csname cat!#2\endcsname%
+       #2@{\noexpand\code{#2}}!%
+       \csname cat!#1\endcsname%
        ##1%
      }%
    }%
@@ -223,7 +243,7 @@
    \toks\tw@\expandafter{\@tempa{|)}}%
    \xdef\after@desc{\the\toks@\the\toks\tw@}}%
   \rlap{\hb@xt@\linewidth{\hfil\normalfont\bfseries
-      [\describecategoryname{#2}]}}%
+      [\describecategoryname{#1}]}}%
   #3%
 }
 
