MHL(1)

✨ NAME ✨

mhl β€” it makes formatted listings of nmh messages. that's it, that's the whole vibe, and it ate πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

/usr/libexec/nmh/mhl [-help] [-version] [-bell | -nobell] [-clear |
     -noclear] [-folder +folder] [-form formfile] [-length lines]
     [-width columns] [-moreproc program] [-nomoreproc] [-fmtproc
     program] [-nofmtproc] [files ...]

🌸 DESCRIPTION 🌸

okay bestie, sit down, hydrate, because mhl is the moment. it's an nmh command for filtering and/or displaying text messages, and it's the default way nmh shows you text messages (it's literally the default showproc, main character energy fr fr πŸ‘‘).

so here's the tea. just like with more, every message you hand over as an argument (or the standard input) gets output. and if you're throwing more than one message file at it, it's gonna prompt you before each one β€” a <RETURN> or <EOT> starts the output, where <RETURN> clears the screen (if appropriate), and <EOT> (usually CTRL-D) suppresses the screen clear. an <INTERRUPT> (usually CTRL-C) aborts the current message output and prompts for the next message (if there even is one), and a <QUIT> (usually CTRL- will terminate the program (without core dump).

now, the -bell option tells mhl to ring the terminal's bell at the end of each page, while -clear tells it to clear the screen at the end of each page (or output a formfeed after each message). both of these switches (and their inverse counterparts) only do anything if the profile entry moreproc is defined but empty, AND mhl is outputting to a terminal. if the moreproc entry is defined and non-empty, and mhl is outputting to a terminal, then mhl will cause the moreproc to be placed between the terminal and mhl, and the switches are just... ignored, bestie, they said not today. furthermore, if you use the -clear switch and mhl's output is directed to a terminal, then mhl consults the TERM and TERMCAP environment variables to figure out your terminal type so it knows how to clear the screen. but if -clear is given and the output is not directed to a terminal (like a pipe or a file), then mhl sends a formfeed after each message. slay.

to override the default moreproc and the profile entry, use the -moreproc program switch. and note: mhl will never start a moreproc if it's invoked on a hardcopy terminal. periodt.

the -length length and -width width switches set the screen length and width respectively. these default to whatever TERMCAP says (if appropriate), otherwise they default to 40 and 80 respectively.

the default format file mhl uses is called mhl.format. mhl first searches for this file in your nmh directory, and then searches in the directory /etc/nmh. you can change that default with the -form formatfile switch.

and finally, the -folder +folder switch sets the nmh folder name, which is used for the "messagename:" field described down below. the environment variable $mhfolder is consulted for the default value, which next, show, and prev initialize appropriately. 🫢


πŸ¦‹ how it actually works (the two-phase moment) πŸ¦‹

mhl operates in two phases:

  1. read and parse the format file
  2. process each message (file)

during phase 1, an internal description of the format is produced as a structured list. during phase 2, that list gets walked for each message, outputting message information under the format constraints from the format file.

the format file can contain info controlling screen clearing, screen size, wrap-around control, transparent text, component ordering, and component formatting. also, you can specify a list of components to ignore, and there are a couple of "special" components defined to provide added functionality. message output will be in the order specified by the order in the format file. iykyk ✨


πŸ’œ format file line forms πŸ’œ

every line of a format file is one of these:

;comment
:cleartext
variable[,variable...]
component:[variable,...]
  • a line beginning with a ; is a comment, and is ignored.
  • a line beginning with a : is clear text, and is output exactly as is.
  • a line containing only a : produces a blank line in the output.
  • a line beginning with "component:" defines the format for the specified component.
  • remaining lines define the global environment.

for example, this line:

width=80,length=40,clearscreen,overflowtext="***",overflowoffset=5

defines the screen size to be 80 columns by 40 rows, specifies that the screen should be cleared prior to each page, that the overflow indentation is 5, and that overflow text should be flagged with "***". iconic.


🌈 all the variables, no cap 🌈

here's every current variable and its argument. if they follow a component, they apply only to that component β€” otherwise their effect is global. and since the whole format gets parsed before any output processing happens, the last global switch setting for a variable applies to the whole message if that variable is used in a global context (i.e., bell, clearscreen, width, length).

  • width β€” integer β€” screen width or component width
  • length β€” integer β€” screen length or component length
  • offset β€” integer β€” positions to indent "component: "
  • overflowtext β€” string β€” text to use at the beginning of an overflow line
  • overflowoffset β€” integer β€” positions to indent overflow lines
  • compwidth β€” integer β€” positions to indent component text after the first line is output
  • uppercase β€” flag β€” output text of this component in all upper case
  • nouppercase β€” flag β€” don't uppercase
  • clearscreen β€” flag/G β€” clear the screen prior to each page
  • noclearscreen β€” flag/G β€” don't clearscreen
  • bell β€” flag/G β€” ring the bell at the end of each page
  • nobell β€” flag/G β€” don't bell
  • component β€” string/L β€” name to use instead of "component" for this component
  • nocomponent β€” flag β€” don't output "component: " for this component
  • center β€” flag β€” center component on line (works for one-line components only)
  • nocenter β€” flag β€” don't center
  • leftadjust β€” flag β€” strip off leading whitespace on each line of text
  • noleftadjust β€” flag β€” don't leftadjust
  • rtrim β€” flag β€” trim whitespace at end of text lines
  • nortrim β€” flag β€” retain whitespace at end of text lines (default)
  • compress β€” flag β€” change newlines in text to spaces
  • nocompress β€” flag β€” don't compress
  • wrap β€” flag β€” Wrap lines that exceed width (default)
  • nowrap β€” flag β€” Do not perform line wrapping
  • split β€” flag β€” don't combine multiple fields into a single field
  • nosplit β€” flag β€” combine multiple fields into a single field
  • newline β€” flag β€” print newline at end of components (this is the default)
  • nonewline β€” flag β€” don't print newline at end of components
  • formatfield β€” string β€” format string for this component (see below)
  • decode β€” flag β€” decode text as RFC 2047 encoded header field
  • addrfield β€” flag β€” field contains addresses
  • datefield β€” flag β€” field contains dates
  • format β€” flag β€” Run component through formatproc filter (body only)
  • noformat β€” flag β€” Do not run component through formatproc filter (default)
  • formatarg β€” string β€” Argument to format filter

to specify the value of integer-valued and string-valued variables, follow their name with an equals-sign and the value. integer-valued variables get decimal values, while string-valued variables get arbitrary text bracketed by double-quotes. and if a value is suffixed by "/G" or "/L", then its value is useful in a global-only or local-only context (respectively). got it? good. πŸ’–


πŸ“ the special bits πŸ“

a line of this form:

ignores=component,...

specifies a list of components which are never output.

the component "MessageName" (case-insensitive) will output the actual message name (file name) preceded by the folder name if one is specified or found in the environment. the format is identical to that produced by the -header option to show.

the component "Extras" will output all of the components of the message which were not matched by explicit components, or included in the ignore list. if this component is not specified, an ignore list is not needed since all non-specified components will be ignored. convenient ✨

if "nocomponent" is not specified, then the component name will be output as it appears in the format file.


πŸ‘‘ the default format file πŸ‘‘

it's literally this:

; mhl.format
;
; default message filter for `show'
;
:
overflowtext="***",overflowoffset=5
leftadjust,compwidth=9
ignores=msgid,message-id,received,content-type,content-transfer-encoding,content-id
Resent-To:formatfield="%(unquote(decode{text}))"
Resent-cc:formatfield="%(unquote(decode{text}))"
Resent-From:formatfield="%(unquote(decode{text}))"
Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>"
To:formatfield="%(unquote(decode{text}))"
cc:formatfield="%(unquote(decode{text}))"
From:formatfield="%(unquote(decode{text}))"
Subject:decode
:
extras:nocomponent
:
body:nocomponent,overflowtext=,overflowoffset=0,noleftadjust

the variable "formatfield" specifies a format string (see mh-format(5)). the flag variables "addrfield" and "datefield" (which are mutually exclusive) tell mhl to interpret the escapes in the format string as either addresses or dates, respectively.

by default, mhl does not apply any formatting string to fields containing address or dates (see mh-mail(5) for a list of these fields). note that this results in faster operation since mhl must parse both addresses and dates in order to apply a format string to them. if you want, mhl can be given a default format string for either address or date fields (but not both). to do this, on a global line specify: either the flag addrfield or datefield, along with the appropriate formatfield variable string. πŸ’…

The β€œformat” flag says: bestie, run this component through the filter program named in the formatproc profile entry. That filter is expected to read from standard input and write to standard output, like a good little pipe citizen. Right now the β€œformat” flag only works for the β€œbody” component β€” the other components are sitting there like πŸ™ˆ. And the component name gets prefixed onto the output after the filter has done its thing. The whole point, the dream, the vision: filter a message body so you get prettier text to drop into a reply. 🌸

A suggested filter for repl(1) is literally this:

body:component=">",overflowtext=">",overflowoffset=0,format,nowrap

If you wanna override the formatproc profile entry, the -fmtproc and -nofmtproc switches are right there, no cap. πŸ’…

The formatarg option hands you a string that gets used as an argument to the format filter. That string goes through mh-format(5) β€” iconic β€” and all the message components are available to play with. And yes, you can stack multiple formatarg options to build up multiple arguments for the format filter. Obsessed. ✨


πŸ“ FILES πŸ“

  • /etc/nmh/mhl.format β€” the message template
  • <mh-dir>/mhl.format β€” use this instead of the standard template if you want your own vibe
  • $HOME/.mh_profile β€” the user profile, where your settings live 🏠

πŸŽ€ PROFILE COMPONENTS πŸŽ€

  • moreproc: β€” the program to use as an interactive front-end
  • formatproc: β€” the program to use as a filter for components that have the β€œformat” flag set

πŸ‘€ SEE ALSO πŸ‘€

show(1), ap(8), dp(8) β€” go read those too, they're giving main character energy πŸ‘‘


✨ DEFAULTS ✨

  • -bell
  • -noclear
  • -length 40
  • -width 80

πŸŒ€ CONTEXT πŸŒ€

None. Literally nothing. Empty. a void. 🫢


πŸ’€ BUGS πŸ’€

There should be some way to pass bell and clear information to the front-end. Currently there isn't. 😭
The β€œnonewline” option interacts badly with β€œcompress” and β€œsplit”. Like, they do not get along. Proceed with caution bestie, this is not a drill.
The β€œformat” option really should work on something other than the body component. It just... doesn't. πŸ™ˆ

And that's the whole page, we made it!! πŸŽ‰ This one's from nmh-1.8, dated 2014-09-15 β€” MHL(1), periodt. Now go forth and format your mail, you gorgeous Unix gremlin. πŸ’–πŸ¦‹πŸ’…

πŸ“¦ where this page comes from