Files
nethack/doc/tmac.nh
G. Branden Robinson ade0c02b20 Make it easier for the Guidebook to find macros.
* doc/Guidebook.mn: Make the Guidebook buildable from the top of the
  source tree, not just inside the "doc" directory.  Try to load its
  "nh" macro package from the current working directory and from "doc".

* doc/tmac.nh: Allocate new register `nH` to the purpose of detecting
  multiple loads, and skip file content if detected.  This is the 1970s
  nroff form of an "#include guard".  groff's "an-ext.tmac" uses the
  same technique for portability.

Also I removed a tab character.  Per the groff Texinfo manual:

     One possibly irritating idiosyncrasy is that tabs should not be
     used to vertically align comments in the source document.  Tab
     characters are not treated as separators between a request name and
     its first argument, nor between arguments.

Here's an example of how one groff macro package works around the
problem.

$ sed -n '402,406p' contrib/mm/m.tmac
.ds LetCN CONFIDENTIAL\"                Confidential default
.ds LetSA To Whom It May Concern:\"     Salutation default
.ds LetAT ATTENTION:\"                  Attention string
.ds LetSJ SUBJECT:\"                    Subject string
.ds LetRN In reference to:\"            Reference string
2024-09-10 06:44:43 -05:00

141 lines
4.4 KiB
Plaintext

.\" NetHack 3.7 tmac.nh $NHDT-Date: $ $NHDT-Branch: $:$NHDT-Revision: $
.
.\" Miscellaneous tmac.n-style macros specifically for nethack's Guidebook.
.\"
.\" Most are modelled after, or variations of, macros in tmac.n whose author
.\" has specified that that file remain unmodified if it gets distributed.
.\" These used to be inline within Guidebook.mn but it was becoming too
.\" cluttered as their number increased. It now uses the '.so' directive
.\" to include this file. (tmac.n is passed to 'roff on the command line.)
.
.\" Protect against being sourced twice.
.nr nH +1
.if \n(nH>1 .nx
.
.\" labeled paragraph start
.\" .PS word
.\" set the width for the label column
.\" .PL word
.\" label for the entry
.\" .PE
.\" clean up
.de PS
.nr PY \\w'\\$1\ -\ 'u \" width of label plus " - "
.nr PX \\w'\ -\ 'u \" width of " - "
.sn \\n(pdu \" tmac.n: inter-paragraph space
.in +\\n(PYu \" additional indent past label (etc)
.si \" tmac.n: start indented section
..
.\" labeled paragraph label (and first line)
.de PL
.br
\\h'|-\\n(PYu'\\$1\\h'|-\\n(PXu'\ -\ \\c \" back up, output the label, then
. \" skip to width-of(" - ") before the
. \" normal indentation, output the " - "
. \" then attach the next line (the
. \" text) without stopping (\c: nroff
. \" section 4.2)
..
.\" labeled paragraph end
.de PE
.ei \" tmac.n: end indented section
.in -\\n(PYu \" undo indent past label (etc)
.sn \\n(pdu \" tmac.n: inter-paragraph space
..
.\" end of labeled paragraph
.
.\"
.\" aligned single character key with SHORT definition (if it overflows one
.\" line, all bets are off)
.\" Usage:
.\" .CC k "definition here"
.nr CZ \w'\fBW' \" width of the key character column
.nr CW \n(CZ/2 \" half the width of the key character column
.de CC
.nr CX \\w'\\fB\\$1'u/2 \" half the width of the key character
.nr CY \\n(CWu-\\n(CXu \" difference between the two half widths
.\" output: move right CR units, print the key letter, move right to
.\" the full width of the column, print " - " and the definition
\\h'|\\n(CYu'\\fB\\$1\\fP\\h'|\\n(CZu'\ -\ \\$2
..
.
.\" .SD = .sd with extra choices for argument; pair with .ED
.\" c - centered (original choice; as of this writing, not used by nethack)
.\" i - indented (default if choice is omitted)
.\" n - not indented
.\" SF - set (1=>indent, 0=>no-indent) by .SD, used by .ED unless centering
.de SD \" start display
. \" look for nested displays -- ILLEGAL
.ie \\n(id>0 .er "display within display"
.el \{\
. nr sf 0 \" don't center by default
. nr SF 1 \" assume indent
. ie '\\$1'c' .nr sf 1 \" center the sucker
. el .if '\\$1'n' .nr SF 0 \" don't indent if 'n'
.\}
.sn \\n(pdu \" a little bit of space
.ev 2 \" switch to display environment
.nf \" what you type is what you get
.if \\n(id=0 .di dd \" start saving text
.rs \" don't eat leading space
.nr id +1 \" increment level of display
..
.\" .ED = .ed with support for \n(SF (indent vs no-indent); pair with .SD
.de ED \" end display
.br \" flush line
.ie \\n(id<=0 .er "end display has no corresponding begin display"
.el \{\
. nr id -1 \" decrement level of display
. if \\n(id=0 \{\
. di \" end diversion
. fi \" resume filling
. in -\\n(piu \" dedent
. ev \" pop environment
. ne \\n(dnu \" be sure you have room
. nf \" don't reprocess display
. rs \" don't eat leading space
. zi \" save indents
. ie \\n(sf .in (\\n(llu-\\n(dlu)/2u \" center
. el .if \\n(SF .in +\\n(piu \" indent
. dd \" drop display
. yi \" restore indents
. \}
.\}
.fi \" resume filling
.sn \\n(pdu \" a little bit of space
..
.
.\" '.UX' is verbatim copy of tmac.n's '.ux' with the exception that
.\" the trademark owner for "UNIX" has been updated.
.de UX \" print "UNIX"
.ie \\n(ux \\&\\$2\\s-1UNIX\\s0\\$1
.el \{\
. nr ux +1 \" mark footnote as dropped
\\&\\$2\\s-1UNIX\\s0\\*(rg\\$1
. fn \" put out the footnote
\\&\\*(rgUNIX is a registered trademark of The Open Group.
. ef \" short and sweet ...
.\}
..
.
.\" .BR - hard line break with vertical padding inserted
.\" $1 - repeat count for amount of padding (optional; default is 1)
.de BR
.ie \\.$==0 .nr bR 1v
.el .nr bR (\\$1-0)v
\0
.sp \\n(bR
.br
..
.\" .UR url
.\" Just a pass-through here; converted to a link when generating HTML.
.de UR
\\$1\\$2
..
.
.\" Don't hyphenate the last word on a page or column. groff and AT&T-
.\" descended troffs use different hyphenation patterns.
.ie \n(.g .hy 6
.el .hy 2
.\"tmac.nh/"