Automatischer Zeilenumbruch nach x Zeichen in Apple Mail die 2.

by hubi on 2/09/2009

Nun, 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:

  1. 12/01/2012der andere Hubi on Mac :) says:

    Super und vielen Dank! - Das habe ich gesucht; auch ich verabscheue die langen Zeilen in jedweden Mails, ein Zeilenumbruch nach 75 - 80 Zeichen ist für eine gute Lesbarkeit aus meiner Sicht angebracht.

    Habe, da ich die Abfrage im Skript nicht jedes Mal möchte, das Script im ersten Abschnitt daher ein wenig modifiziert:

    try
    tell application "Mail"
    activate
    set line_char_count to 80 as integer

    activate
    tell application "System Events"
    usw. usf. siehe oben

    Beste Grüße -

    der andere Hubi on Mac :)

Write a comment:

CAPTCHA:


eight − = 7