[vox-tech] Email formatting fun

Jonathan McPherson vox-tech@lists.lugod.org
Tue, 20 Apr 2004 10:23:20 -0700


Hey all,

I use mutt to read my email, and vim to compose messages.  Judging from
the headers on the mail messages around the list, many of you are in the
same boat.

I like my email to be as well-formatted as possible.  Towards that end,
I use a paragraph formatter named par[1] to format my email messages.
par reflows paragraphs and chooses line breaks that are optimal (in
some sense), using a dynamic programming algorithm that outperforms the
greedy one used by "fmt" and most other mail clients.

Anyhow, my messages tend to consist of at least three different classes
of text:

1. Paragraphs - the most basic unit.  These may contain a quote prefix
   (>, etc), an indent, or some other prefix, which must be preserved as
   the paragraph is reflowed to email line length.

2. Lists - such as this one.  These are formatted as "hanging indent"
   paragraphs.  For instance, this list is formatted as a set of
   paragraphs with a hanging indent of 3.

3. Raw - text that should not be touched by the formatter.  For
   instance, code snippets and my signature could be considered to be
   "raw" text.

At any rate, my current system of email formatting is somewhat
time-consuming.  Parts of the email that fall into class (1) must be
passed to par; parts that fall into class (2) must be passed to par with
a special argument indicating the level of hanging indent to be used;
and parts that fall into class (3) must not be passed to par.  Thus, I
must manually highlight groups of lines and filter them through par with
the appropriate command-line options.  This only takes a few seconds,
but it's something that could be automated.

So, the question for you Unix/text gurus is simply: what do you use
for your email? and do you have any recommendations for how I could
automate the above process?  Ideally I'd like to just have the entire
email filtered through one script that Does the Right Thing.

I'm thinking about using awk to separate the classes and pass them to
par, but I'm having more trouble doing that than seems reasonable.  Of
course, I've never used awk before, so... (-:

Thanks! 

-jam

[1] http://www.nicemice.net/par/