Compromising line breaks in mutt_

🇺🇦 Resources to help support the people of Ukraine. 🇺🇦
August 30, 2022 @23:07

My Wyse WY-60 Terminal in GLORIOUS green A long time ago terminals were physical things that only displayed ASCII text and they typically defaulted to 80 columns. This lead a tremendous amount of software and convention forming around line lengths of between 70 and 80 characters. These days the world has moved on and RFC 3676 came around to try to find a way to bridge the gap between those of us who prefer 80 columns and monospaced fonts and those who have never seen, or just don't care about that world.

Over the years I've hard wrapped most of the things I write on computers. I type into an editor and as I approach the right-hand margin of the window I press the return key to move down to the start of the next line. (I suppose this is partially a hold over from learning to type in some horrific DOS editors that lacked word wrapping instead of in a word processing environment or even a typewriter with automatic carrage return.) Functionally this inserts a newline character (typically abbreviated as \n, also known as ASCII 10) into the file. As noted in the RFC this can lead to potentially ugly and difficult to read text if the recipient is not using a monospace font or a display capable of at least 80 columns. It turns out that in general there are several solutions to this — in the case of this article the HTML output produced from this markdown file carries the newlines but encapsulates each paragraph inside <p> </p> tags which allows the browser to manage the line wrapping. The hope is that format=flowed can do the same for e-mail. Readers of this blog may already know that I prefer mutt as my primary e-mail client in part due to its extreme flexability. Sure enough a little searching revealed several references to people using format=flowed successfully. Happily they even included some options for vim to make it easy.

The following tweaks to my .muttrc successfully produced a format=flowed e-mail.

set text_flowed
set editor="vim -c 'set formatoptions+=w' -c 'set textwidth=72'"

The first command tells mutt to generate the proper Content-Type: text/plain; charset=us-ascii; format=flowed header and the second line tells mutt to invoke vim with two additional configuration commands. The first adds w to the set of formatoptions and the second sets textwidth to 72 (a personal preference). This produces an instance of vim where I do not have to hard wrap text.

Mutt showing a format=flowed message

In the end, I get what I want — a nicely formatted message on an 80 column display — and the recipient (most of the time) gets a nicely formatted message regardless of any terrible display decisions their software makes. Brief testing shows that while Apple's mail software does the right thing, Microsoft's does not.

Comment via e-mail. Subscribe via RSS.