Automatischer Zeilenumbruch nach x Zeichen in Apple Mail die 2.

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 =)

This entry was posted in Apple Mail. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. der andere Hubi on Mac :)
    Posted January 12, 2012 at 10:43 pm | Permalink

    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 :)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


eight × 9 =

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...