Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Pre-wrap lines in Mail.app Apps
Left to its own devices, Mail.app tends to break long lines in messages in stupid places (I've seen it do it at apostrophes, colons, all sorts of weird places). Depending on the mail client the recipient is using, this can make the sender look rather illiterate. One workaround is to re-flow paragraphs yourself using fmt.

First install the incredibly useful TextExtras package as described in this hint. Then define a "user pipe" which sends the current selection to fmt and replaces the current selection with the result by editing your .TEUserPipes.plist file. Mine looks like this. Note that it binds this pipe to Command-\.

Now in any Cocoa text editor you can highlight some text, hit Command-\ and it will get reformatted so the lines are between 65 and 75 chars long (fmt's default setting). Obviously this method can be easily extended to call any of the other command line text processing tools from inside a Cocoa window.

That's useful in itself, but to be honest I'd love to be told a better way of coping with this line length madness.
    •    
  • Currently 4.83 / 5
  You rated: 5 / 5 (6 votes cast)
 
[12,302 views]  

Pre-wrap lines in Mail.app | 4 comments | Create New Account
Click here to return to the 'Pre-wrap lines in Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Try angle brackets
Authored by: vin on Jun 08, '02 12:14:45PM

Try enclosing long URLs in angle brackets so the link <http://www.xlr8yourmac.com/feedback/itunes/itunes_disk_burn.html?whoknowswhatelseIcanaddtothisurlinordertomakeitlongenoughtodemonstartethatitwillnotbreak> should not be broken.



[ Reply to This | # ]
All text...
Authored by: robg on Jun 08, '02 12:30:34PM

The problem is that it's not just URL's. Mail seems to wrap normal lines at odd spaces, too. And on one of the X4U mailin lists, even the angle-bracket test failed.

The Mail team has stated that this will be improved in upcoming releases, I believe.

-rob.



[ Reply to This | # ]
All text...
Authored by: peyote on Jun 10, '02 10:47:09AM

It shouldn't be that hard for them to improve it, after all they have the
source code for fmt in their tree to crib from...

I tend to use trn+vi to compose Usenet news, so I use fmt from there
all the time for flowing paragraphs, and can't recall it breaking
lines in silly places in about 10 years of use...



[ Reply to This | # ]
Updated version of Pre-wrap lines in Mail.app
Authored by: persson on Jan 14, '05 06:08:30PM
There must be a 'cocoa' way to do this, but learning more about TextExtras seemed worthwhile.

Updated to use new TextExtras script model. Place in "Library/Application Support/TextExtras/Scripts/". Alter to taste. Must enable "Run Startup Script" in TextExtras.

Decided to use fold instead of fmt. Need a sed guru or perl hack to help build a more robust wrap script to call.


#! /bin/sh
#
# foldAll.sh - folds all text, breaking only on whitespace at 71 chars
# Limitations:
# - breaks all lines greater than 70 chars, regardless of spacing, quotation, 
#   etc.
# - Does not compact spaces, leading or trailing
#
# -- TextExtras User Script Info --
# %%%{TEName=Wrap All}%%%
# %%%{TEInput=AllText}%%%
# %%%{TEOutput=ReplaceAllText}%%%
# %%%{TEKeyEquivalent=@$|}%%%
#
# %%%{TENewScript}%%%
# %%%{TEName=Wrap Selected}%%%
# %%%{TEInput=Selection}%%%
# %%%{TEOutput=ReplaceSelection}%%%
# %%%{TEKeyEquivalent=@$}}%%%
#

# fold seems more versatile than fmt for this task
WRAP_CMD=fold

# any lines greater than 70 characters are wrapped, using the last blank char
# within the first 70
WRAP_ARGS="-s -w71"

echo -n "%%%{TESelection}%%%"
${WRAP_CMD} ${WRAP_ARGS} <&0
echo -n "%%%{TESelection}%%%"



[ Reply to This | # ]