BSD 4_3_Reno release
[unix-history] / usr / src / share / doc / usd / 24.troff / m2
CommitLineData
95f51977 1.\" @(#)m2 6.2 (Berkeley) 4/21/86
a909d424
KM
2.\"
3.tr |
4.rm mx
5.br
6.mh
7Line Length and Indenting
8.pg
9The maximum line length for fill mode may be set with \fBll\fR.
10The indent may be set with \fBin\fR;
11an indent applicable to \fIonly\fR the \fInext\fR output line may be set with \fBti\fR.
12The line length includes indent space but \fInot\fR
13page offset space.
14The line-length minus the indent is the basis for centering with \fBce\fR.
15The effect of \fBll\fR, \fBin\fR, or \fBti\fR
16is delayed, if a partially collected line exists,
17until after that line is output.
18In fill mode the length of text on an output line is less than or equal to
19the line length minus the indent.
20The current line length and indent are available in registers \fB.l\fR and \fB.i\fR respectively.
21The length of \fIthree-part titles\fR produced by \fBtl\fR
22(see \(sc14) is \fIindependently\fR set by \fBlt\fR.
23.h1
24.bt
25\fB&ll\fI|\(+-N\fR 6.5\|in previous E,\fBm\fR Line length is set to \(+-\fIN\fR.
26In \*(TR the maximum (line-length)+(page-offset) is about 7.54 inches.
27.bt
28\fB&in\fI|\(+-N\fR \fIN\(eq\^\fR0 previous B,E,\fBm\fR Indent is set to \fI\(+-N\fR.
29The indent is prepended to each output line.
30.bt
31\fB&ti\fI|\(+-N\fR - ignored B,E,\fBm\fR Temporary indent.
32The \fInext\fR output text line will be indented a distance \fI\(+-N\fR
33with respect to the current indent.
34The resulting total indent may not be negative.
35The current indent is not changed.
36.mh
37Macros, Strings, Diversion, and Position Traps
38.sc
39Macros and strings.
40A \fImacro\fR is a named set of arbitrary \fIlines\fR that may be invoked by name or
41with a \fItrap\fR.
42A \fIstring\fR is a named string of \fIcharacters\fR,
43\fInot\fR including a newline character,
44that may be interpolated by name at any point.
45Request, macro, and string names share the \fIsame\fR name list.
46Macro and string names
47may be one or two characters long and may usurp previously defined
48request, macro, or string names.
49Any of these entities may be renamed with \fBrn\fR
50or removed with \fBrm\fR.
51Macros are created by \fBde\fR and \fBdi\fR, and appended to by \fBam\fR and \fBda\fR;
52\fBdi\fR and \fBda\fR cause normal output to be stored in a macro.
53Strings are created by \fBds\fR and appended to by \fBas\fR.
54A macro is invoked in the same way as a request;
55a control line beginning \fB.\fIxx\fR will interpolate the contents of macro \fIxx\fR.
56The remainder of the line may contain up to nine \fIarguments\fR.
57The strings \fIx\fR and \fIxx\fR are interpolated at any desired point with
58\fB\e\(**\fIx\fR and \fB\e\(**(\fIxx\fR respectively.
59String references and macro invocations may be nested.
60.sc
61Copy mode input interpretation.
62During the definition and extension
63of strings and macros (not by diversion)
64the input is read in \fIcopy mode\fR.
65The input is copied without interpretation
66\fIexcept\fR that:
67.x1
68.ds + \v'-.1m'\s-4\(bu\s+4\v'+.1m'
69\*+ The contents of number registers indicated by \fB\en\fR are interpolated.
70\*+ Strings indicated by \fB\e\(**\fR are interpolated.
71\*+ Arguments indicated by \fB\e$\fR are interpolated.
72\*+ Concealed newlines indicated by \fB\e\fR(newline) are eliminated.
73\*+ Comments indicated by \fB\e"\fR are eliminated.
74\*+ \fB\et\fR and \fB\ea\fR are interpreted as \s-1ASCII\s+1 horizontal tab and \s-1SOH\s+1 respectively (\(sc9).
75\*+ \fB\e\e\fR is interpreted as \fB\e\fR.
76\*+ \fB\e.\fR is interpreted as "\fB.\fR".
77.x2
78These interpretations can be suppressed by
79prepending
80a \fB\e\fR.
81For example, since \fB\e\e\fR maps into a \fB\e\fR, \fB\e\en\fR will copy as \fB\en\fR which
82will be interpreted as a number register indicator when the
83macro or string is reread.
84.sc
85Arguments.
86When a macro is invoked by name, the remainder of the line is
87taken to contain up to nine arguments.
88The argument separator is the space character, and arguments
89may be surrounded by double-quotes to permit imbedded space characters.
90Pairs of double-quotes may be imbedded in double-quoted arguments to
91represent a single double-quote.
92If the desired arguments won't fit on a line,
93a concealed newline may be used to continue on the next line.
94.pg
95When a macro is invoked the \fIinput level\fR is \fIpushed down\fR and
96any arguments available at the previous level become unavailable
97until the macro is completely read and the previous level is restored.
98A macro's own arguments can be interpolated at \fIany\fR point
99within the macro with \fB\e$\fIN\fR, which interpolates the \fIN\fR\^th
100argument
101(1\(<=\fIN\fR\^\(<=9).
102If an invoked argument doesn't exist,
103a null string results.
104For example, the macro \fIxx\fR may be defined by
105.x1
106.ftB
107.ta .75i
108&de xx \e"begin definition
109Today is \e\e$1 the \e\e$2.
110&. \e"end definition
111.ftR
112.x2
113and called by
114.x1
115.ftB
116&xx Monday 14th
117.ftR
118.x2
119to produce the text
120.x1
121.ftB
122Today is Monday the 14th.
123.ftR
124.x2
125Note that the \fB\e$\fR
126was concealed in the definition with a prepended \fB\e\fR.
127The number of currently available
128arguments is in the \fB.$\fR register.
129.pg
130No arguments are available at the top (non-macro) level
131in this implementation.
132Because string referencing is implemented
133as a input-level push down,
134no arguments are available from \fIwithin\fR a string.
135No arguments are available within a trap-invoked macro.
136.pg
137Arguments are copied in \fIcopy mode\fR onto a stack
138where they are available for reference.
139The mechanism does not allow an argument to contain
140a direct reference to a \fIlong\fR string
141(interpolated at copy time) and it is advisable to
142conceal string references (with an extra \fB\e\fR\|)
143to delay interpolation until argument reference time.
144.sc
145Diversions.
146Processed output may be diverted into a macro for purposes
147such as footnote processing (see Tutorial \(scT5)
148or determining the horizontal and vertical size of some text for
149conditional changing of pages or columns.
150A single diversion trap may be set at a specified vertical position.
151The number registers \fBdn\fR and \fBdl\fR respectively contain the
152vertical and horizontal size of the most
153recently ended diversion.
154Processed text that is diverted into a macro
155retains the vertical size of each of its lines when reread
156in \fInofill\fR mode
157regardless of the current \fIV\fR.
158Constant-spaced (\fBcs\fR) or emboldened (\fBbd\fR) text that is diverted
159can be reread correctly only if these modes are again or still in effect
160at reread time.
161One way to do this is to imbed in the diversion the appropriate
162\fBcs\fR or \fBbd\fR requests with the \fItransparent\fR
163mechanism described in \(sc10.6.
164.pg
165Diversions may be nested
166and certain parameters and registers
167are associated
168with the current diversion level
169(the top non-diversion level may be thought of as the
1700th diversion level).
171These are the diversion trap and associated macro,
172no-space mode,
173the internally-saved marked place (see \fBmk\fR and \fBrt\fR),
174the current vertical place (\fB.d\fR register),
175the current high-water text base-line (\fB.h\fR register),
176and the current diversion name (\fB.z\fR register).
177.sc
178Traps.
179Three types of trap mechanisms are available\(empage traps, a diversion trap, and
180an input-line-count trap.
181Macro-invocation traps may be planted using \fBwh\fR at any page position including the top.
182This trap position may be changed using \fBch\fR.
183Trap positions at or below the bottom of the page
184have no effect unless or until
185moved to within the page or rendered effective by an increase in page length.
186Two traps may be planted at the \fIsame\fR position only by first planting them at different
187positions and then moving one of the traps;
188the first planted trap will conceal the second unless and until the first one is moved
189(see Tutorial Examples \(scT5).
190If the first one is moved back, it again conceals the second trap.
191The macro associated with a page trap is automatically
192invoked when a line of text is output whose vertical size \fIreaches\fR
193or \fIsweeps past\fR the trap position.
194Reaching the bottom of a page springs the top-of-page trap, if any,
195provided there is a next page.
196The distance to the next trap position is available in the \fB.t\fR register;
197if there are no traps between the current position and the bottom of the page,
198the distance returned is the distance to the page bottom.
199.pg
200A macro-invocation trap effective in the current diversion may be planted using \fBdt\fR.
201The \fB.t\fR register works in a diversion; if there is no subsequent trap a \fIlarge\fR
202distance is returned.
c5bdbd2a 203For a description of input-line-count traps, see the \fBit\fR request below.
a909d424
KM
204.h1
205.bt
206\fB&de\fI|xx|yy\fR - \fI.yy=\fB..\fR - Define or redefine the macro \fIxx\fR.
207The contents of the macro begin on the next input line.
208Input lines are copied in \fIcopy mode\fR until the definition is terminated by a
209line beginning with \fB.\fIyy\fR,
210whereupon the macro \fIyy\fR is called.
211In the absence of \fIyy\fR, the definition
212is terminated by a
213line beginning with "\fB..\fR".
214A macro may contain \fBde\fR requests
215provided the terminating macros differ
216or the contained definition terminator is concealed.
217\&"\fB..\fR" can be concealed as
218\fB\e\e..\fR which will copy as \fB\e..\fR and be reread as "\fB..\fR".
219.bt
220\fB&am\fI|xx|yy\fR - \fI.yy=\fB..\fR - Append to macro (append version of \fBde\fR).
221.bt
222\fB&ds\fI|xx|string\fR - ignored - Define a string
223\fIxx\fR containing \fIstring\fR.
224Any initial double-quote in \fIstring\fR is stripped off to permit
225initial blanks.
226.bt
227\fB&as\fI|xx|string\fR - ignored - Append
228\fIstring\fR to string \fIxx\fR
229(append version of \fBds\fR).
230.bt
231\fB&rm\fI|xx\fR - ignored - Remove
232request, macro, or string.
233The name \fIxx\fR is removed from the name list and
234any related storage space is freed.
235Subsequent references will have no effect.
236.bt
237\fB&rn\fI|xx|yy\fR - ignored - Rename request, macro, or string
238\fIxx\fR to \fIyy\fR.
239If \fIyy\fR exists, it is first removed.
240.bt
241\fB&di|\fIxx\fR - end D Divert output to macro \fIxx\fR.
242Normal text processing occurs during diversion
243except that page offsetting is not done.
244The diversion ends when the request \fBdi\fR or \fBda\fR is encountered without an argument;
245extraneous
246requests of this type should not appear when nested diversions are being used.
247.bt
248\fB&da|\fIxx\fR - end D Divert, appending to \fIxx\fR
249(append version of \fBdi\fR).
250.bt
251\fB&wh\fI|N|xx\fR - - \fBv\fR Install
252a trap to invoke \fIxx\fR at page position \fIN;\fR
253a \fInegative N\fR will be interpreted with respect to the
254page \fIbottom\fR.
255Any macro previously planted at \fIN\fR is replaced by \fIxx\fR.
256A zero \fIN\fR refers to the \fItop\fR of a page.
257In the absence of \fIxx\fR, the first found trap at \fIN\fR, if any, is removed.
258.bt
259\fB&ch\fI|xx|N\fR - - \fBv\fR Change
260the trap position for macro \fIxx\fR to be \fIN\fR.
261In the absence of \fIN\fR, the trap, if any, is removed.
262.bt
263\fB&dt\fI|N|xx\fR - off D,\fBv\fR Install a diversion trap
264at position \fIN\fR in the \fIcurrent\fR diversion to invoke
265macro \fIxx\fR.
266Another \fBdt\fR will redefine the diversion trap.
267If no arguments are given, the diversion trap is removed.
268.bt
269\fB&it\fI|N|xx\fR - off E Set an input-line-count trap
270to invoke the macro \fIxx\fR after \fIN\fR lines of \fItext\fR input
271have been read
272(control or request lines don't count).
273The text may be in-line text or
274text interpolated by inline or trap-invoked macros.
275.bt
276\fB&em\fI|xx\fR none none - The
277macro \fIxx\fR will be invoked
278when all input has ended.
279The effect is the same as if the contents of \fIxx\fR had been at the end
280of the last file processed.
281.mh
282Number Registers
283.pg
284A variety of parameters are available to the user as
285predefined, named \fInumber registers\fR (see Summary and Index, page 7).
286In addition, the user may define his own named registers.
287Register names are one or two characters long and \fIdo not\fR conflict
288with request, macro, or string names.
289Except for certain predefined read-only registers,
290a number register can be read, written, automatically
291incremented or decremented, and interpolated
292into the input in a variety of formats.
293One common use of user-defined registers is to
294automatically number sections, paragraphs, lines, etc.
295A number register may be used any time numerical input is expected or desired
296and may be used in numerical \fIexpressions\fR (\(sc1.4).
297.pg
298Number registers are created and modified using \fBnr\fR, which
299specifies the name, numerical value, and the auto-increment size.
300Registers are also modified, if accessed
301with an auto-incrementing sequence.
302If the registers \fIx\fR and \fIxx\fR both contain
303\fIN\fR and have the auto-increment size \fIM\fR,
304the following access sequences have the effect shown:
305.TS
306center box;
307c2|c2|c
308c2|c2|c2
309l2|c2|c2
310l2|c2|c2
311l2|l2|c2.
312 Effect on Value
313Sequence Register Interpolated
314_
315\fB\en\fIx\fR none \fIN\fR
316\fB\en(\fIxx\fR none \fIN\fR
317\fB\en+\fIx\fR \fIx\fR incremented by \fIM\fR \fIN+M\fR
318\fB\en\-\fIx\fR \fIx\fR decremented by \fIM\fR \fIN\-M\fR
319\fB\en+(\fIxx\fR \fIxx\fR incremented by \fIM\fR \fIN+M\fR
320\fB\en\-(\fIxx\fR \fIxx\fR decremented by \fIM\fR \fIN\-M\fR
321.TE
322When interpolated, a number register is converted to
323decimal (default),
324decimal with leading zeros,
325lower-case Roman,
326upper-case Roman,
327lower-case sequential alphabetic,
328or
329upper-case sequential alphabetic
330according to the format specified by \fBaf\fR.
331.h1
332.bt
f6d73574 333\fB&nr\fI|R|\(+-N|M\fR - - \fBu\fR \
a909d424
KM
334The number register \fIR\fR is assigned the value \fI\(+-N\fR
335with respect to the previous value, if any.
336The increment for auto-incrementing is set to \fIM\fR.
337.bt
338\fB&af\fI|R|c\fR arabic - - Assign format \fIc\fR to register \fIR\fR.
339The available formats are:
340.TS
341center box;
342c2|c
343c2|c
344c2|l.
345 Numbering
346Format Sequence
347_
348\fB1\fR 0,1,2,3,4,5,...
349\fB001\fR 000,001,002,003,004,005,...
350\fBi\fR 0,i,ii,iii,iv,v,...
351\fBI\fR 0,I,II,III,IV,V,...
352\fBa\fR 0,a,b,c,...,z,aa,ab,...,zz,aaa,...
353\fBA\fR 0,A,B,C,...,Z,AA,AB,...,ZZ,AAA,...
354.TE
355An arabic format having \fIN\fR digits
356specifies a field width of \fIN\fR digits (example 2 above).
357The read-only registers and the \fIwidth\fR function (\(sc11.2)
358are always arabic.
359.bt
360\fB&rr\fI|R\fR - ignored - Remove register \fIR\fR.
361If many registers are being created dynamically, it
362may become necessary to remove no longer used registers
363to recapture internal storage space for newer registers.