X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/a5d802695539b981a4001f99d62dd961948b8795..678b6c0f7fe1d62abdf249b173a8a922c4e5c1d3:/doc/sod.sty?ds=sidebyside

diff --git a/doc/sod.sty b/doc/sod.sty
index 9fffa17..9c9aaf8 100644
--- a/doc/sod.sty
+++ b/doc/sod.sty
@@ -124,9 +124,30 @@
 %% Environment for setting programs.  Newlines are explicit, because
 %% otherwise I need comments in weird places to make the vertical spacing
 %% come out properly.  You can write `\obeylines' if you really want to.
-\def\prog{\codeface\quote\tabbing}
+\def\@prog{\let\prog@@cr\@tabcr\let\@tabcr\@progcr\codeface\tabbing}
+\def\prog{\quote\@prog}
 \def\endprog{\endtabbing\endquote}
+\let\nprog\@prog
+\let\endnprog\endtabbing
 \def\ind{\quad\=\+\kill}
+\def\@progcr{\futurelet\@tempa\@progcr@i}
+{\def\:{\gdef\@progcr@sp}\: {\@progcr}}
+\def\@progcr@i{%
+  \ifx\@tempa\@sptoken\let\next@\@progcr@sp\else
+  \if1\ifx\@tempa[1\else
+      \ifx\@tempa*1\else
+      0\fi\fi
+    \let\next@\prog@@cr\else
+  \if1\ifx\@tempa+1\else
+      \ifx\@tempa-1\else
+      0\fi\fi
+    \let\next@\@progcr@ii\else
+  \let\next@\@progcr@a\fi\fi\fi
+  \next@}
+\def\@progcr@a{\prog@@cr*{}\ignorespaces}
+\def\@progcr@ii#1{\csname @progcr@#1\endcsname\ignorespaces}
+\@namedef{@progcr@+}{\prog@@cr[\medskipamount]}
+\@namedef{@progcr@-}{\prog@@cr*[\jot]}
 
 %% Put a chunk of text in a box.
 \newenvironment{boxy}[1][\q@]{%
@@ -207,10 +228,9 @@
   \if@nobreak\else\par\goodbreak\fi%
   \global\@dheadfirsttrue%
   \begingroup%
-    \codeface%
     \let\@endparenv\relax%
     \clubpenalty\@M \widowpenalty\@M \interlinepenalty50%
-    \tabbing#1\endtabbing%
+    \@prog#1\endtabbing%
   \endgroup%
   \penalty\@M\@afterheading%
   \list{}{\rightmargin\z@\topsep\z@}\item%
@@ -223,5 +243,14 @@
 \def\desc@#1#2#3{\desc@begin{\dhead@{#1}{#2}{#3}}}
 \let\enddescribe\desc@end
 
+\def\descref#1{\@ifnextchar[{\descref@i{#1}}{\descref@ii{#1}{}}}
+\def\descref@i#1[#2]{\descref@ii{#1}{ #2}}
+\def\descref@ii#1#2#3{%
+  \code{#1}#2 (page~%
+  {\let\protect\@empty%
+   \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\pageref{#3:#1}}\@tempa}%
+  )%
+}
+
 %%%----- That's all, folks --------------------------------------------------
 \endinput
