]> diplodocus.org Git - nmh/blob - man/mh-format.man
pending-release-notes: add mhshow's "-prefer", and mh-format's %(kibi/kilo)
[nmh] / man / mh-format.man
1 .TH MH-FORMAT %manext5% "January 10, 2015" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
5 .SH NAME
6 mh-format \- format file for nmh message system
7 .SH DESCRIPTION
8 Several
9 .B nmh
10 commands utilize either a
11 .I format
12 string or a
13 .I format
14 file during their execution. For example,
15 .B scan
16 uses a format string which directs it how to generate the scan listing
17 for each message;
18 .B repl
19 uses a format file which directs it
20 how to generate the reply to a message, and so on.
21 .PP
22 There are a few alternate scan listing formats available
23 in
24 .IR nmh/etc/scan.time ,
25 .IR nmh/etc/scan.size ,
26 and
27 .IR nmh/etc/scan.timely .
28 Look in
29 .I nmh/etc
30 for other
31 .B scan
32 and
33 .B repl
34 format files which may have been written at your site.
35 .PP
36 It suffices to have your local
37 .B nmh
38 expert actually write new format
39 commands or modify existing ones. This manual section explains how to
40 do that. Note: familiarity with the C
41 .B printf
42 routine is assumed.
43 .PP
44 A format string consists of ordinary text, and special multi-character
45 escape sequences which begin with `%'. When specifying a format
46 string, the usual C backslash characters are honored: `\\b', `\\f',
47 `\\n', `\\r', and `\\t'. Continuation lines in format files end with
48 `\\' followed by the newline character. A literal `%' can be inserted into
49 a format file by using the sequence `%%'.
50 .\" TALK ABOUT SYNTAX FIRST, THEN SEMANTICS
51 .SS SYNTAX
52 Format strings are built around
53 .IR "escape sequences" .
54 There are three types of escape sequences: header
55 .IR components ,
56 built-in
57 .IR functions ,
58 and flow
59 .IR control .
60 Comments may be inserted in most places where a function argument is
61 not expected. A comment begins with `%;' and ends with a (non-escaped)
62 newline.
63 .PP
64 A
65 .I component
66 escape is specified as
67 .RI `%{ component }',
68 and
69 exists for each header found in the message being processed. For example
70 .RI `%{ date }'
71 refers to the \*(lqDate:\*(rq field of the appropriate message.
72 All component escapes have a string value. Normally, component values are
73 compressed by converting any control characters (tab and newline included)
74 to spaces, then eliding any leading or multiple spaces. However, commands
75 may give different interpretations to some component escapes; be sure
76 to refer to each command's manual entry for complete details. Some commands
77 (such as
78 .B ap
79 and
80 .BR mhl )
81 use a special component
82 .RI `%{ text }'
83 to refer to the text being processed; see their respective man pages for
84 details and examples.
85 .PP
86 A
87 .I function
88 escape is specified as
89 .RI `%( function )'.
90 All functions are built-in, and most have a string or numeric value.
91 A function escape may have an
92 .IR argument .
93 The argument follows the function escape: separating
94 whitespace is discarded:
95 .RI `%( function " " argument )'.
96 .PP
97 In addition to literal numbers or strings,
98 the argument to a function escape can be another function, a component,
99 or a control escape. When the argument is a function or a
100 component, they are listed without a leading `%'. When control escapes
101 are used as function arguments, they written as normally, with
102 a leading `%';
103 .SS "Control escapes"
104 .PP
105 A
106 .I control
107 escape is one of: `%<', `%?', `%|', or `%>'.
108 These are combined into the conditional execution construct:
109 .PP
110 .RS 5
111 .nf
112 .RI "%< " condition " " "format-text"
113 .RI "%? " condition " " "format-text"
114 \&...
115 .RI "%| " "format-text"
116 %>
117 .fi
118 .RE
119 .PP
120 Extra white space is shown here only for clarity. These
121 constructs may be nested without ambiguity. They form a general
122 .B if\-elseif\-else\-endif
123 block where only one of the
124 format-texts
125 is interpreted. In other
126 words, `%<' is like the "if", `%?' is like the "elseif", `%|' is like
127 "else", and `%>' is like "endif".
128 .PP
129 A `%<' or `%?' control escape causes its condition to be evaluated.
130 This condition is a
131 .I component
132 or
133 .IR function .
134 For integer valued functions or components, the condition is true
135 if the function return or component value is non-zero, and false if zero.
136 For string valued functions or components, the condition is true
137 if the function return or component value is
138 a non-empty string, and false for an empty string.
139 .PP
140 The `%?' control escape is optional, and may there may be more
141 than one `%?' control escape in a conditional block.
142 The `%|' control escape
143 is also optional, but may be included at most once.
144 .SS "Function escapes"
145 Functions expecting an argument generally
146 require an argument of a particular type.
147 In addition to the number and string types,
148 these include:
149 .PP
150 .RS 5
151 .nf
152 .ta +\w'Argument 'u +\w'An optional component, 'u
153 .I "Argument Description Example Syntax"
154 literal A literal number %(\fIfunc\fR 1234)
155 or string %(\fIfunc\fR text string)
156 comp Any component %(\fIfunc\fR\^{\fIin-reply-to\fR\^})
157 date A date component %(\fIfunc\fR\^{\fIdate\fR\^})
158 addr An address component %(\fIfunc\fR\^{\fIfrom\fR\^})
159 expr Nothing %(\fIfunc\fR)
160 or a subexpression %(\fIfunc\fR\^(\fIfunc2\fR\^))
161 or control escape %(\fIfunc\fR %<{\fIreply-to\fR\^}%|%{\fIfrom\fR\^}%>)
162 .fi
163 .RE
164 .PP
165 The types
166 .I date
167 and
168 .I addr
169 have the same syntax as
170 .IR comp ,
171 but require that the header component be a date string, or address
172 string, respectively.
173 .PP
174 Most arguments not of type
175 .IR expr
176 are required.
177 When escapes are nested (via expr arguments), evaluation is done from inner-most to outer-most.
178 As noted above, for the
179 expr
180 argument type,
181 functions and components are written without a
182 leading `%'.
183 Control escape arguments must use a leading `%', preceded by a space.
184 .PP
185 For example,
186 .PP
187 .RS 5
188 .nf
189 %<(mymbox{from}) To: %{to}%>
190 .fi
191 .RE
192 .PP
193 writes the value of the header component \*(lqFrom:\*(rq to the
194 internal register named str; then (\fImymbox\fR\^) reads str and
195 writes its result to the internal register named
196 .IR num ;
197 then the control escape evaluates
198 .IR num .
199 If
200 .IR num
201 is non-zero, the
202 string \*(lqTo:\*(rq is printed followed by the value of the
203 header component \*(lqTo:\*(rq.
204 .SS Evaluation
205 The evaluation of format strings is performed
206 by a small virtual machine.
207 The machine is capable of evaluating nested expressions
208 as described above, and in addition
209 has an integer register
210 .IR num ,
211 and a text string register
212 .IR str .
213 When a function escape that
214 accepts an optional argument is processed,
215 and the argument is not present, the current value of either
216 .I num
217 or
218 .I str
219 is used as the argument: which register is
220 used depends on the function, as listed below.
221 .PP
222 Component escapes write the value of their message header in
223 .IR str .
224 Function escapes write their return value in
225 .I num
226 for functions returning integer or boolean values, and in
227 .I str
228 for functions returning string values. (The boolean type is a subset
229 of integers with usual values 0=false and 1=true.) Control escapes
230 return a boolean value, setting
231 .I num
232 to 1 if the last explicit condition
233 evaluated by a `%<' or `%?' control
234 succeeded, and 0 otherwise.
235 .PP
236 All component escapes, and those function escapes which return an
237 integer or string value, evaluate to their value as well as setting
238 .I str
239 or
240 .IR num .
241 Outermost escape expressions in
242 these forms will print
243 their value, but outermost escapes which return a boolean value
244 do not result in printed output.
245 .SS Functions
246 The function escapes may be roughly grouped into a few categories.
247 .PP
248 .RS 5
249 .nf
250 .ta \w'Fformataddr 'u +\w'Aboolean 'u +\w'Rboolean 'u
251 .I "Function Argument Result Description"
252 msg integer message number
253 cur integer message is current (0 or 1)
254 unseen integer message is unseen (0 or 1)
255 size integer size of message
256 strlen integer length of \fIstr\fR
257 width integer column width of terminal
258 charleft integer bytes left in output buffer
259 timenow integer seconds since the UNIX epoch
260 me string the user's mailbox (username)
261 myhost string the user's local hostname
262 myname string the user's name
263 localmbox string the complete local mailbox
264 eq literal boolean \fInum\fR == \fIarg\fR
265 ne literal boolean \fInum\fR != \fIarg\fR
266 gt literal boolean \fInum\fR > \fIarg\fR
267 match literal boolean \fIstr\fR contains \fIarg\fR
268 amatch literal boolean \fIstr\fR starts with \fIarg\fR
269 plus literal integer \fIarg\fR plus \fInum\fR
270 minus literal integer \fIarg\fR minus \fInum\fR
271 multiply literal integer \fInum\fR multiplied by \fIarg\fR
272 divide literal integer \fInum\fR divided by \fIarg\fR
273 modulo literal integer \fInum\fR modulo \fIarg\fR
274 num literal integer Set \fInum\fR to \fIarg\fR.
275 num integer Set \fInum\fR to zero.
276 lit literal string Set \fIstr\fR to \fIarg\fR.
277 lit string Clear \fIstr\fR.
278 getenv literal string Set \fIstr\fR to environment value of \fIarg\fR
279 profile literal string Set \fIstr\fR to profile component \fIarg\fR
280 value
281 .\" dat literal int return value of dat[arg]
282 nonzero expr boolean \fInum\fR is non-zero
283 zero expr boolean \fInum\fR is zero
284 null expr boolean \fIstr\fR is empty
285 nonnull expr boolean \fIstr\fR is non-empty
286 void expr Set \fIstr\fR or \fInum\fR
287 comp comp string Set \fIstr\fR to component text
288 compval comp integer Set \fInum\fR to \*(lq\fBatoi\fR(\fIcomp\fR\^)\*(rq
289 .\" compflag comp integer Set \fInum\fR to component flags bits (internal)
290 .\" decodecomp comp string Set \fIstr\fR to RFC 2047 decoded component text
291 decode expr string decode \fIstr\fR as RFC 2047 (MIME-encoded)
292 component
293 unquote expr string remove RFC 2822 quotes from \fIstr\fR
294 trim expr trim trailing whitespace from \fIstr\fR
295 kilo expr string express in SI units: 15.9K, 2.3M, etc.
296 %(kilo) scales by factors of 1000,
297 kibi expr string express in IEC units: 15.5Ki, 2.2Mi.
298 %(kibi) scales by factors of 1024.
299 putstr expr print \fIstr\fR
300 putstrf expr print \fIstr\fR in a fixed width
301 putnum expr print \fInum\fR
302 putnumf expr print \fInum\fR in a fixed width
303 .\" addtoseq literal add msg to sequence (LBL option)
304 putlit expr print \fIstr\fR without space compression
305 zputlit expr print \fIstr\fR without space compression;
306 \fIstr\fR must occupy no width on display
307 bold string set terminal bold mode
308 underline string set terminal underlined mode
309 standout string set terminal standout mode
310 resetterm string reset all terminal attributes
311 hascolor boolean terminal supports color
312 fgcolor literal string set terminal foreground color
313 bgcolor literal string set terminal background color
314 formataddr expr append \fIarg\fR to \fIstr\fR as a
315 (comma separated) address list
316 concataddr expr append \fIarg\fR to \fIstr\fR as a
317 (comma separated) address list,
318 including duplicates,
319 see Special Handling
320 putaddr literal print \fIstr\fR address list with
321 \fIarg\fR as optional label;
322 get line width from \fInum\fR
323 .fi
324 .RE
325 .PP
326 The (\fIme\fR\^) function returns the username of the current user. The
327 (\fImyhost\fR\^) function returns the
328 .B localname
329 entry in
330 .IR mts.conf ,
331 or the local hostname if
332 .B localname
333 is not configured. The (\fImyname\fR\^) function will return the value of
334 the
335 .B SIGNATURE
336 environment variable if set, otherwise will return the passwd GECOS field
337 (truncated at the first comma if it contains one) for
338 the current user. The (\fIlocalmbox\fR\^) function will return the complete
339 form of the local mailbox, suitable for use in a \*(lqFrom\*(rq header.
340 It will return the
341 .RI \*(lq Local-Mailbox \*(rq
342 profile entry if it is set; if it is not, it will be equivalent to:
343 .PP
344 .RS 5
345 .nf
346 %(myname) <%(me)@%(myhost)>
347 .fi
348 .RE
349 .PP
350 The following functions require a date component as an argument:
351 .PP
352 .RS 5
353 .nf
354 .ta \w'Fformataddr 'u +\w'Aboolean 'u +\w'Rboolean 'u
355 .I "Function Argument Return Description"
356 sec date integer seconds of the minute
357 min date integer minutes of the hour
358 hour date integer hours of the day (0-23)
359 wday date integer day of the week (Sun=0)
360 day date string day of the week (abbrev.)
361 weekday date string day of the week
362 sday date integer day of the week known?
363 (1=explicit,0=implicit,\-1=unknown)
364 mday date integer day of the month
365 yday date integer day of the year
366 mon date integer month of the year
367 month date string month of the year (abbrev.)
368 lmonth date string month of the year
369 year date integer year (may be > 100)
370 zone date integer timezone in minutes
371 tzone date string timezone string
372 szone date integer timezone explicit?
373 (1=explicit,0=implicit,\-1=unknown)
374 date2local date coerce date to local timezone
375 date2gmt date coerce date to GMT
376 dst date integer daylight savings in effect? (0 or 1)
377 clock date integer seconds since the UNIX epoch
378 rclock date integer seconds prior to current time
379 tws date string official RFC 822 rendering
380 pretty date string user-friendly rendering
381 nodate date integer returns 1 if date is invalid
382 .fi
383 .RE
384 .PP
385 These functions require an address component as an argument.
386 The return value of functions noted with `*' is computed from
387 the first address present in the header component.
388 .PP
389 .RS 5
390 .nf
391 .ta \w'Fformataddr 'u +\w'Aboolean 'u +\w'Rboolean 'u
392 .I "Function Argument Return Description"
393 proper addr string official RFC 822 rendering
394 friendly addr string user-friendly rendering
395 addr addr string mbox@host or host!mbox rendering*
396 pers addr string the personal name*
397 note addr string commentary text*
398 mbox addr string the local mailbox*
399 mymbox addr integer list has the user's address? (0 or 1)
400 getmymbox addr string the user's (first) address,
401 with personal name
402 getmyaddr addr string the user's (first) address,
403 without personal name
404 host addr string the host domain*
405 nohost addr integer no host was present (0 or 1)*
406 type addr integer host type* (0=local,1=network,
407 \-1=uucp,2=unknown)
408 path addr string any leading host route*
409 ingrp addr integer address was inside a group (0 or 1)*
410 gname addr string name of group*
411 .fi
412 .RE
413 .PP
414 (A clarification on (\fImymbox\fR\^{\fIcomp\fR\^}) is in order.
415 This function checks each of the addresses in the header component
416 \*(lq\fIcomp\fR\*(rq against the user's mailbox name and any
417 .RI \*(lq Alternate-Mailboxes \*(rq.
418 It returns true if any address matches,
419 however, it also returns true if the \*(lq\fIcomp\fR\*(rq header is not
420 present in the message. If needed, the (\fInull\fR\^) function can be
421 used to explicitly test for this case.)
422 .SS Formatting
423 When a function or component escape is interpreted and the result will
424 be immediately printed, an optional field width can be specified to
425 print the field in exactly a given number of characters. For example, a
426 numeric escape like %4(\fIsize\fR\^) will print at most 4 digits of the
427 message size; overflow will be indicated by a `?' in the first position
428 (like `?234'). A string escape like %4(\fIme\fR\^) will print the first 4
429 characters and truncate at the end. Short fields are padded at the right
430 with the fill character (normally, a blank). If the field width argument
431 begins with a leading zero, then the fill character is set to a zero.
432 .PP
433 The functions (\fIputnumf\fR\^) and (\fIputstrf\fR\^)
434 print their result in exactly the number of characters
435 specified by their leading field width argument. For example,
436 %06(\fIputnumf\fR\^(\fIsize\fR\^)) will print the message
437 size in a field six characters wide filled with leading zeros;
438 %14(\fIputstrf\^\fR{\fIfrom\^\fR}) will print the \*(lqFrom:\*(rq header
439 component in fourteen characters with trailing spaces added as needed.
440 For \fIputstrf\fR, using a negative value for the field width causes
441 right-justification of the string within the field, with padding on
442 the left up to the field width.
443 The functions (\fIputnum\fR\^) and
444 (\fIputstr\fR\^) are somewhat special: they print their result in the minimum number of characters
445 required, and ignore any leading field width argument. The (\fIputlit\fR\^)
446 function outputs the exact contents of the str register without any changes
447 such as duplicate space removal or control character conversion.
448 The (\fIzputlit\fR\^) function similarly outputs the exact contents of
449 the str register, but requires that those contents not occupy any
450 output width. It can therefore be used for outputting terminal escape
451 sequences.
452 .PP
453 There are a limited number of function escapes to output terminal escape
454 sequences. These sequences are retrieved from the
455 .IR terminfo (5)
456 database according to the current terminal setting. The (\fIbold\fR\^),
457 (\fIunderline\fR\^), and (\fIstandout\fR\^) escapes set bold mode,
458 underline mode, and standout mode respectively.
459 .PP
460 (\fIhascolor\fR\^)
461 can be used to determine if the current terminal supports color.
462 (\fIfgcolor\fR\^) and (\fIbgcolor\fR\^) set the foreground and
463 background colors respectively. Both of these escapes take one literal
464 argument, the color name, which can be one of: black, red, green, yellow,
465 blue, magenta, cyan, white. (\fIresetterm\fR\^) resets all terminal
466 attributes back to their default setting.
467 .PP
468 All of these terminal escape should be used in conjunction with
469 (\fIzputlit\fR\^) (preferred) or (\fIputlit\fR\^), as the normal
470 (\fIputstr\fR\^) function will strip out control characters.
471 .PP
472 The available output width is kept in an internal register; any output
473 past this width will be truncated. The one exception to this is
474 (\fIzputlit\fR\^) functions will still be executed in case a terminal reset
475 code is being placed at the end of the line.
476 .SS Special Handling
477 A few functions have different behavior depending on what command they are
478 being invoked from.
479 .PP
480 In
481 .BR repl
482 the (\fIformataddr\fR\^) function stores all email addresses encountered into
483 an internal cache and will use this cache to suppress duplicate addresses.
484 If you need to create an address list that includes previously-seen
485 addresses you may use the (\fIconcataddr\fR\^) function, which is identical
486 to (\fIformataddr\fR\^) in all other respects. Note that (\fIconcataddr\fR\^)
487 will NOT add addresses to the duplicate-suppression cache.
488 .SS Other Hints and Tips
489 Sometimes to format function writers it is confusing as to why output is
490 duplicated. The general rule to remember is simple: If a function or
491 component escape is used where it starts with a %, then it will generate
492 text in the output file. Otherwise, it will not.
493 .PP
494 A good example is a simple attempt to generate a To: header based on
495 the From: and Reply-To: headers:
496 .PP
497 .RS 5
498 .nf
499 %(formataddr %<{reply-to}%|%{from})%(putaddr To: )
500 .fi
501 .RE
502 .PP
503 Unfortuantely if the Reply-to: header is NOT present, the output line that is
504 generated will be something like:
505 .PP
506 .RS 5
507 .nf
508 My From User <from@example.com>To: My From User <from@example.com>
509 .fi
510 .RE
511 .PP
512 What went wrong? When performing the test for the
513 .B if
514 clause (%<), the component is not output because it is considered an
515 argument to the
516 .B if
517 statement (hence the rule about the lack of % applies). But the component
518 escape in our
519 .B else
520 statement (everything after the `%|') is NOT an argument to anything; the
521 syntax is that it is written with a %, and thus the value of that component
522 is output. This also has the side effect of setting the
523 .I str
524 register, which is later picked up by the (\fIformataddr\fR\^) function
525 and then output by (\fIputaddr\fR\^). This format string has another bug
526 as well; there should always be a valid width value in the
527 .I num
528 register when (\fIputaddr\fR\^) is called, otherwise bad formatting can take
529 place.
530 .PP
531 The solution is to use the (\fIvoid\fR\^) function; this will prevent the
532 function or component from outputting any text. With this in place (and
533 using (\fIwidth\fR\^) to set the
534 .I num
535 register for the width, a better implementation would look like:
536 .PP
537 .RS 3
538 .nf
539 %(formataddr %<{reply-to}%|%(void{from})%(void(width))%(putaddr To: )
540 .fi
541 .RE
542 .PP
543 It should be noted here that the side-effects of functions and component
544 escapes still are in force: as a result each component
545 test in the
546 .B if\-elseif\-else\-endif
547 clause sets the
548 .I str
549 register.
550 .PP
551 As an additional note, the (\fIformataddr\fR\^) and (\fIconcataddr\fR\^)
552 functions have special behavior when it comes to the
553 .I str
554 register. The starting point of the register is saved and is used to
555 build up entries in the address list.
556 .PP
557 You will find the
558 .B fmttest
559 utility invaluable when debugging problems with format strings.
560 .SS Examples
561 With all this in mind,
562 here's the default format string for
563 .BR scan .
564 It's been divided into several pieces for readability.
565 The first part is:
566 .PP
567 .RS
568 .nf
569 %4(msg)%<(cur)+%| %>%<{replied}\-%?{encrypted}E%| %>
570 .fi
571 .RE
572 .PP
573 which says that the message number should be printed in four digits.
574 If the message is the current message then a `+' else a space should
575 be printed; if a \*(lqReplied:\*(rq field is present then a `\-'
576 else if an \*(lqEncrypted:\*(rq field is present then an `E' otherwise
577 a space should be printed. Next:
578 .PP
579 .RS
580 .nf
581 %02(mon{date})/%02(mday{date})
582 .fi
583 .RE
584 .PP
585 the month and date are printed in two digits (zero filled) separated by
586 a slash. Next,
587 .PP
588 .RS 5
589 .nf
590 %<{date} %|*%>
591 .fi
592 .RE
593 .PP
594 If a \*(lqDate:\*(rq field was present,
595 then a space is printed, otherwise a `*'.
596 Next,
597 .PP
598 .RS 5
599 .nf
600 %<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>
601 .fi
602 .RE
603 .PP
604 if the message is from me, and there is a \*(lqTo:\*(rq header,
605 print \*(lqTo:\*(rq followed by a \*(lquser-friendly\*(rq rendering of the
606 first address in the \*(lqTo:\*(rq field; any MIME-encoded
607 characters are decoded into the actual characters.
608 Continuing,
609 .PP
610 .RS 5
611 .nf
612 %<(zero)%17(decode(friendly{from}))%>
613 .fi
614 .RE
615 .PP
616 if either of the above two tests failed,
617 then the \*(lqFrom:\*(rq address is printed
618 in a mime-decoded, \*(lquser-friendly\*(rq format.
619 And finally,
620 .PP
621 .RS 5
622 .nf
623 %(decode{subject})%<{body}<<%{body}>>%>
624 .fi
625 .RE
626 .PP
627 the mime-decoded subject and initial body (if any) are printed.
628 .PP
629 For a more complicated example, next consider
630 a possible
631 .I replcomps
632 format file.
633 .PP
634 .RS 5
635 .nf
636 %(lit)%(formataddr %<{reply-to}
637 .fi
638 .RE
639 .PP
640 This clears
641 .I str
642 and formats the \*(lqReply-To:\*(rq header
643 if present. If not present, the else-if clause is executed.
644 .PP
645 .RS 5
646 .nf
647 %?{from}%?{sender}%?{return-path}%>)\\
648 .fi
649 .RE
650 .PP
651 This formats the
652 \*(lqFrom:\*(rq, \*(lqSender:\*(rq and \*(lqReturn-Path:\*(rq
653 headers, stopping as soon as one of them is present. Next:
654 .PP
655 .RS 5
656 .nf
657 %<(nonnull)%(void(width))%(putaddr To: )\\n%>\\
658 .fi
659 .RE
660 .PP
661 If the \fIformataddr\fR result is non-null, it is printed as
662 an address (with line folding if needed) in a field \fIwidth\fR
663 wide with a leading label of \*(lqTo:\*(rq.
664 .PP
665 .RS 5
666 .nf
667 %(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\\
668 .fi
669 .RE
670 .PP
671 .I str
672 is cleared, and the \*(lqTo:\*(rq and \*(lqCc:\*(rq headers, along with the user's
673 address (depending on what was specified with
674 the \*(lq\-cc\*(rq switch to \fIrepl\fR\^) are formatted.
675 .PP
676 .RS 5
677 .nf
678 %<(nonnull)%(void(width))%(putaddr cc: )\\n%>\\
679 .fi
680 .RE
681 .PP
682 If the result is non-null, it is printed as above with a
683 leading label of \*(lqcc:\*(rq.
684 .PP
685 .RS 5
686 .nf
687 %<{fcc}Fcc: %{fcc}\\n%>\\
688 .fi
689 .RE
690 .PP
691 If a
692 .B \-fcc
693 .I folder
694 switch was given to
695 .B repl
696 (see
697 .IR repl (1)
698 for more details about %{\fIfcc\fR\^}),
699 an \*(lqFcc:\*(rq header is output.
700 .PP
701 .RS 5
702 .nf
703 %<{subject}Subject: Re: %{subject}\\n%>\\
704 .fi
705 .RE
706 .PP
707 If a subject component was present,
708 a suitable reply subject is output.
709 .PP
710 .RS 5
711 .nf
712 %<{message-id}In-Reply-To: %{message-id}\\n%>\\
713 %<{message-id}References: %<{references} %{references}%>\\
714 %{message-id}\\n%>
715 \-\-\-\-\-\-\-\-
716 .fi
717 .RE
718 .PP
719 If a message-id component was present, an \*(lqIn-Reply-To:\*(rq header is
720 output including the message-id, followed by a \*(lqReferences:\*(rq
721 header with references, if present, and the message-id.
722 As with all
723 plain-text, the row of dashes are output as-is.
724 .PP
725 This last part is a good example for a little more elaboration.
726 Here's that part again in pseudo-code:
727 .PP
728 .RS 5
729 .nf
730 .ta .5i 1i 1.5i 2i
731 if (comp_exists(message-id)) then
732 print (\*(lqIn-reply-to: \*(rq)
733 print (message-id.value)
734 print (\*(lq\\n\*(rq)
735 endif
736 if (comp_exists(message-id)) then
737 print (\*(lqReferences: \*(rq)
738 if (comp_exists(references)) then
739 print(references.value);
740 endif
741 print (message-id.value)
742 print (\*(lq\\n\*(rq)
743 endif
744 .fi
745 .RE
746 .PP
747 .\" (Note that this pseudocode begs the question ``why not just
748 .\" support this syntax?'' MH has been hacked on for a long time...)
749 .\".PP
750 One more example: Currently,
751 .B nmh
752 supports very
753 large message numbers, and it is not uncommon for a folder
754 to have far more than 10000 messages.
755 .\" (Indeed, the original MH
756 .\" tutorial document by Rose and Romine is entitled "How to
757 .\" process 200 messages a day and still get some real work
758 .\" done." The authors apparently only planned to get
759 .\" real work done for about 50 days per folder.)
760 Nontheless (as noted above)
761 the various scan format strings are inherited
762 from older MH versions, and are generally hard-coded to 4
763 digits of message number before formatting problems
764 start to occur.
765 The nmh format strings can be modified to behave more sensibly with larger
766 message numbers:
767 .PP
768 .RS
769 .nf
770 %(void(msg))%<(gt 9999)%(msg)%|%4(msg)%>
771 .fi
772 .RE
773 .PP
774 The current message number is placed in \fInum\fP.
775 (Note that
776 .RI ( msg )
777 is an int function, not a component.)
778 The
779 .RI ( gt )
780 conditional
781 is used to test whether the message number
782 has 5
783 or more digits.
784 If so, it is printed at full width, otherwise
785 at 4 digits.
786 .SH "SEE ALSO"
787 .IR scan (1),
788 .IR repl (1),
789 .IR fmttest (1),
790 .SH CONTEXT
791 None