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


Click here to return to the 'Updated version of 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.
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 | # ]