Automatischer Zeilenumbruch nach x Zeichen in Apple Mail die 2.
by hubi on 2/09/2009Nun, nach dem berechtigten Einwand von Alain M. Lafon in den Kommentaren und seinem Vorschlag mit fmt, habe ich mit der Hilfe von Rastafari bei Apfeltalk eine entsprechend schnellere und schlankere Version des Skriptes erstellt. Es führt die Shortcuts (copy&paste) selber aus. Also einfach nur noch in der Nachricht den Text auswählen, das Skript starten und fertig =)
try
tell application "Mail"
activate
display dialog "Umbruch nach ca. wieviel Zeichen?:" default answer "55"
set line_char_count to (text returned of the result) as integer
activate
tell application "System Events"
keystroke "c" using command down
end tell
set thetext to the clipboard
set myoutput to ""
repeat with a in every paragraph of thetext
set b to (do shell script "export LANG=UTF-8 && echo " & quoted form of a & " |fmt -p -w " & line_char_count)
set myoutput to myoutput & b & return
end repeat
set the clipboard to myoutput
tell application "System Events"
keystroke "v" using command down & shift down & option down
end tell
end tell
on error msg
error msg
end try
Man könnte natürlich den Loop in dem jede Zeile durchlaufen wird auch noch in den Shell-Script-Teil einbauen, das ist mit aber gerade einfach zu umständlich und so wie es jetzt ist, reicht mir die Geschwindigkeit auch aus =)
There is 1 comment in this article: