.TH MH-FORMAT %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
mh-format \- format file for nmh message system
.SH SYNOPSIS
.TH MH-FORMAT %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
.SH NAME
mh-format \- format file for nmh message system
.SH SYNOPSIS
-Several \fInmh\fR commands utilize either a \fIformat\fR string or a
-\fIformat\fR file during their execution. For example, \fIscan\fR\0(1)
+Several
+.B nmh
+commands utilize either a
+.I format
+string or a
+.I format
+file during their execution. For example,
+.B scan
-in %etcdir%/scan.time, %etcdir%/scan.size, and %etcdir%/scan.timely.
-Look in %etcdir% for other \fIscan\fR and \fIrepl\fR format files which
-may have been written at your site.
-
-It suffices to have your local \fInmh\fR expert actually write new format
+in
+.IR %etcdir%/scan.time ,
+.IR %etcdir%/scan.size ,
+and
+.IR %etcdir%/scan.timely .
+Look in
+.I %etcdir%
+for other
+.B scan
+and
+.B repl
+format files which may have been written at your site.
+.PP
+It suffices to have your local
+.B nmh
+expert actually write new format
string, the usual C backslash characters are honored: `\\b', `\\f',
`\\n', `\\r', and `\\t'. Continuation lines in format files end with
`\\' followed by the newline character.
.\" TALK ABOUT SYNTAX FIRST, THEN SEMANTICS
string, the usual C backslash characters are honored: `\\b', `\\f',
`\\n', `\\r', and `\\t'. Continuation lines in format files end with
`\\' followed by the newline character.
.\" TALK ABOUT SYNTAX FIRST, THEN SEMANTICS
-There are three types of \fIescape\fR sequences: header
-\fIcomponents\fR, built-in \fIfunctions\fR, and flow \fIcontrol\fR.
-
-A \fIcomponent\fR escape is specified as `%{\fIcomponent\fR\^}', and
+.SS SYNTAX
+There are three types of escape sequences: header
+.IR components ,
+built-in
+.IR functions ,
+and flow
+.IR control .
+.PP
+A
+.I component
+escape is specified as
+.RI `%{ component }',
+and
All component escapes have a string value. Normally, component values are
compressed by converting any control characters (tab and newline included)
to spaces, then eliding any leading or multiple spaces. However, commands
may give different interpretations to some component escapes; be sure
to refer to each command's manual entry for complete details.
All component escapes have a string value. Normally, component values are
compressed by converting any control characters (tab and newline included)
to spaces, then eliding any leading or multiple spaces. However, commands
may give different interpretations to some component escapes; be sure
to refer to each command's manual entry for complete details.
-.ne 12
-.Uh "Control-flow escapes"
-A \fIcontrol\fR escape is one of: `%<', `%?', `%|', or `%>'.
+.SS "Control-flow escapes"
+A
+.I control
+escape is one of: `%<', `%?', `%|', or `%>'.
Extra white space is shown here only for clarity. These
constructs may be nested without ambiguity. They form a general
Extra white space is shown here only for clarity. These
constructs may be nested without ambiguity. They form a general
-\fBif\-elseif\-else\-endif\fP block where only one of the \fIformat
-text\fP segments is interpreted.
-
+.B if\-elseif\-else\-endif
+block where only one of the
+.I format text
+segments is interpreted.
+.PP
These control escapes test whether the function or component value is
non-zero (for integer-valued escapes), or non-empty (for string-valued
escapes).
These control escapes test whether the function or component value is
non-zero (for integer-valued escapes), or non-empty (for string-valued
escapes).
If this test evaulates true, then the format text up to the next
corresponding control escape (one of `%|', `%?', or `%>') is interpreted
normally. Next, all format text (if any) up to the corresponding `%>'
control escape is skipped. The `%>' control escape is not interpreted;
normal interpretation resumes after the `%>' escape.
If this test evaulates true, then the format text up to the next
corresponding control escape (one of `%|', `%?', or `%>') is interpreted
normally. Next, all format text (if any) up to the corresponding `%>'
control escape is skipped. The `%>' control escape is not interpreted;
normal interpretation resumes after the `%>' escape.
If the test evaluates false, however, then the format text up to
the next corresponding control escape (again, one of `%|', `%?', or
`%>') is skipped, instead of being interpreted. If the control escape
If the test evaluates false, however, then the format text up to
the next corresponding control escape (again, one of `%|', `%?', or
`%>') is skipped, instead of being interpreted. If the control escape
was `%|', then the format text up to the corresponding `%>' escape is
interpreted normally. As above, the `%>' escape is not interpreted and
normal interpretation resumes after the `%>' escape.
was `%|', then the format text up to the corresponding `%>' escape is
interpreted normally. As above, the `%>' escape is not interpreted and
normal interpretation resumes after the `%>' escape.
The `%?' control escape and its following format text is optional, and may
be included zero or more times. The `%|' control escape and its following
format text is also optional, and may be included zero or one times.
The `%?' control escape and its following format text is optional, and may
be included zero or more times. The `%|' control escape and its following
format text is also optional, and may be included zero or one times.
comp Any header component %(\fIfunc\fR\^{\fIin-reply-to\fR\^})
date A date component %(\fIfunc\fR\^{\fIdate\fR\^})
addr An address component %(\fIfunc\fR\^{\fIfrom\fR\^})
expr An optional component, %(\fIfunc\fR\^(\fIfunc2\fR\^))
function or control, %(\fIfunc\fR %<{\fIreply-to\fR\^}%|%{\fIfrom\fR\^}%>)
comp Any header component %(\fIfunc\fR\^{\fIin-reply-to\fR\^})
date A date component %(\fIfunc\fR\^{\fIdate\fR\^})
addr An address component %(\fIfunc\fR\^{\fIfrom\fR\^})
expr An optional component, %(\fIfunc\fR\^(\fIfunc2\fR\^))
function or control, %(\fIfunc\fR %<{\fIreply-to\fR\^}%|%{\fIfrom\fR\^}%>)
-
-All arguments except those of type \fIexpr\fR are required. For the
-\fIexpr\fR argument type, the leading `%' must be omitted for component
+.PP
+All arguments except those of type
+.IR expr
+are required. For the
+.I expr
+argument type, the leading `%' must be omitted for component
and function escape arguments, and must be present (with a leading space)
for control escape arguments.
and function escape arguments, and must be present (with a leading space)
for control escape arguments.
-with an integer register \fInum\fR, and a text string register \fIstr\fR.
-When a function escape is processed, if it accepts an optional \fIexpr\fR
+with an integer register
+.IR num
+, and a text string register
+.IR str .
+When a function escape is processed, if it accepts an optional
+.I expr
-\fInum\fR or \fIstr\fR as appropriate.
-
-.Uh "Return values"
-Component escapes write the value of their message header in \fIstr\fR.
-Function escapes write their return value in \fInum\fR for functions
-returning \fIinteger\fR or \fIboolean\fR values, and in \fIstr\fR for
-functions returning string values. (The \fIboolean\fR type is a subset
+.I num
+or
+.I str
+as appropriate.
+
+.SS "Return values"
+Component escapes write the value of their message header in
+.IR str .
+Function escapes write their return value in
+.I num
+for functions returning integer or boolean values, and in
+.I str
+for functions returning string values. (The boolean type is a subset
-\fIinteger\fR or \fIstring\fR value, pass this value back to their caller
-in addition to setting \fIstr\fR or \fInum\fR. These escapes will print
+integer or string value, pass this value back to their caller
+in addition to setting
+I str
+or
+.IR num .
+These escapes will print
-sequence. Escapes which return a \fIboolean\fR value do pass this value
-back to their caller in \fInum\fP, but will never print out the value.
-
+sequence. Escapes which return a boolean value do pass this value
+back to their caller in
+.IR num ,
+but will never print out the value.
+.PP
+.RS 5
msg integer message number
cur integer message is current
unseen integer message is unseen
msg integer message number
cur integer message is current
unseen integer message is unseen
putnum expr print \fInum\fR
putnumf expr print \fInum\fR in a fixed width
.\" addtoseq literal add msg to sequence (LBL option)
putnum expr print \fInum\fR
putnumf expr print \fInum\fR in a fixed width
.\" addtoseq literal add msg to sequence (LBL option)
sec date integer seconds of the minute
min date integer minutes of the hour
hour date integer hours of the day (0-23)
sec date integer seconds of the minute
min date integer minutes of the hour
hour date integer hours of the day (0-23)
tws date string official 822 rendering
pretty date string user-friendly rendering
nodate date integer \fIstr\fR not a date string
tws date string official 822 rendering
pretty date string user-friendly rendering
nodate date integer \fIstr\fR not a date string
These functions require an address component as an argument.
The return value of functions noted with `*' pertain only to
the first address present in the header component.
These functions require an address component as an argument.
The return value of functions noted with `*' pertain only to
the first address present in the header component.
proper addr string official 822 rendering
friendly addr string user-friendly rendering
addr addr string mbox@host or host!mbox rendering*
proper addr string official 822 rendering
friendly addr string user-friendly rendering
addr addr string mbox@host or host!mbox rendering*
putaddr literal print \fIstr\fR address list with
\fIarg\fR as optional label;
get line width from \fInum\fR
putaddr literal print \fIstr\fR address list with
\fIarg\fR as optional label;
get line width from \fInum\fR
When escapes are nested, evaluation is done from inner-most to outer-most.
The outer-most escape must begin with `%'; the inner escapes must not.
For example,
When escapes are nested, evaluation is done from inner-most to outer-most.
The outer-most escape must begin with `%'; the inner escapes must not.
For example,
-
-writes the value of the header component \*(lqFrom:\*(rq to \fIstr\fR\^;
-then (\fImymbox\fR\^) reads \fIstr\fR and writes its result to \fInum\fR;
-then the control escape evaluates \fInum\fR. If \fInum\fR is non-zero,
-the string \*(lqTo: \*(rq is printed followed by the value of the header
+.fi
+.RE
+.PP
+writes the value of the header component \*(lqFrom:\*(rq to
+.IR str ;
+then (\fImymbox\fR\^) reads
+.I str
+and writes its result to
+.IR num ;
+then the control escape evaluates
+.IR num .
+If
+.I num
+is non-zero, the string \*(lqTo:\*(rq is printed followed by the value of the header
A minor explanation of (\fImymbox\fR\^{\fIcomp\fR\^}) is in order.
In general, it checks each of the addresses in the header component
\*(lq\fIcomp\fR\*(rq against the user's mailbox name and any
A minor explanation of (\fImymbox\fR\^{\fIcomp\fR\^}) is in order.
In general, it checks each of the addresses in the header component
\*(lq\fIcomp\fR\*(rq against the user's mailbox name and any
however, it also returns true if the \*(lq\fIcomp\fR\*(rq header is not
present in the message. If needed, the (\fInull\fR\^) function can be
used to explicitly test for this condition.
however, it also returns true if the \*(lq\fIcomp\fR\*(rq header is not
present in the message. If needed, the (\fInull\fR\^) function can be
used to explicitly test for this condition.
When a function or component escape is interpreted and the result will
be immediately printed, an optional field width can be specified to
print the field in exactly a given number of characters. For example, a
When a function or component escape is interpreted and the result will
be immediately printed, an optional field width can be specified to
print the field in exactly a given number of characters. For example, a
characters and truncate at the end. Short fields are padded at the right
with the fill character (normally, a blank). If the field width argument
begins with a leading zero, then the fill character is set to a zero.
characters and truncate at the end. Short fields are padded at the right
with the fill character (normally, a blank). If the field width argument
begins with a leading zero, then the fill character is set to a zero.
As above, the functions (\fIputnumf\fR\^) and (\fIputstrf\fR\^)
print their result in exactly the number of characters
specified by their leading field width argument. For example,
As above, the functions (\fIputnumf\fR\^) and (\fIputstrf\fR\^)
print their result in exactly the number of characters
specified by their leading field width argument. For example,
the left up to the field width. The functions (\fIputnum\fR\^) and
(\fIputstr\fR\^) print their result in the minimum number of characters
required, and ignore any leading field width argument.
the left up to the field width. The functions (\fIputnum\fR\^) and
(\fIputstr\fR\^) print their result in the minimum number of characters
required, and ignore any leading field width argument.
The available output width is kept in an internal register; any output
past this width will be truncated.
The available output width is kept in an internal register; any output
past this width will be truncated.
Comments may be inserted in most places where a function argument is
not expected. A comment begins with `%;' and ends with a (non-escaped)
newline.
Comments may be inserted in most places where a function argument is
not expected. A comment begins with `%;' and ends with a (non-escaped)
newline.
which says that the message number should be printed in four digits,
if the message is the current message then a `+' else a space should
be printed, and if a \*(lqReplied:\*(rq field is present then a `\-'
else if an \*(lqEncrypted:\*(rq field is present then an `E' otherwise
a space should be printed. Next:
which says that the message number should be printed in four digits,
if the message is the current message then a `+' else a space should
be printed, and if a \*(lqReplied:\*(rq field is present then a `\-'
else if an \*(lqEncrypted:\*(rq field is present then an `E' otherwise
a space should be printed. Next:
If a \*(lqDate:\*(rq field was present,
then a space is printed, otherwise a `*'.
Next,
If a \*(lqDate:\*(rq field was present,
then a space is printed, otherwise a `*'.
Next,
if the message is from me,
and there is a \*(lqTo:\*(rq header,
print `To:' followed by a \*(lquser-friendly\*(rq rendering of the
first address in the \*(lqTo:\*(rq field.
Continuing,
if the message is from me,
and there is a \*(lqTo:\*(rq header,
print `To:' followed by a \*(lquser-friendly\*(rq rendering of the
first address in the \*(lqTo:\*(rq field.
Continuing,
if either of the above two tests failed,
then the \*(lqFrom:\*(rq address is printed
in a \*(lquser-friendly\*(rq format.
And finally,
if either of the above two tests failed,
then the \*(lqFrom:\*(rq address is printed
in a \*(lquser-friendly\*(rq format.
And finally,
This formats the
\*(lqFrom:\*(rq, \*(lqSender:\*(rq and \*(lqReturn-Path:\*(rq
headers, stopping as soon as one of them is present. Next:
This formats the
\*(lqFrom:\*(rq, \*(lqSender:\*(rq and \*(lqReturn-Path:\*(rq
headers, stopping as soon as one of them is present. Next:
If the \fIformataddr\fR result is non-null, it is printed as
an address (with line folding if needed) in a field \fIwidth\fR
If the \fIformataddr\fR result is non-null, it is printed as
an address (with line folding if needed) in a field \fIwidth\fR
-
-\fIstr\fR is cleared, and the
-\*(lqTo:\*(rq and \*(lqCc:\*(rq headers, along with the user's
-address
-(depending on what was specified with
+.fi
+.RE
+.PP
+.I str
+is cleared, and the \*(lqTo:\*(rq and \*(lqCc:\*(rq headers, along with the user's
+address (depending on what was specified with
If a subject component was present,
a suitable reply subject is output.
If a subject component was present,
a suitable reply subject is output.
If a date component was present, an \*(lqIn-Reply-To:\*(rq header is
output with the preface \*(lqYour message of \*(rq. If the date was
parseable, it is output in a user-friendly format, otherwise it is
output as-is. The message-id is included if present. As with all
plain-text, the row of dashes are output as-is.
If a date component was present, an \*(lqIn-Reply-To:\*(rq header is
output with the preface \*(lqYour message of \*(rq. If the date was
parseable, it is output in a user-friendly format, otherwise it is
output as-is. The message-id is included if present. As with all
plain-text, the row of dashes are output as-is.
This last part is a good example for a little more elaboration.
Here's that part again in pseudo-code:
This last part is a good example for a little more elaboration.
Here's that part again in pseudo-code:
Although this seems complicated,
in point of fact,
this method is flexible enough to extract individual fields and print them in
any format the user desires.
Although this seems complicated,
in point of fact,
this method is flexible enough to extract individual fields and print them in
any format the user desires.
scan(1), repl(1), ap(8), dp(8)
scan(1), repl(1), ap(8), dp(8)