« Safari: Untergetaucht oder irrelevant? | Zurück zur Hauptseite | A History of the GUI »

05.05.05

PerlTidy aus SubEthaEdit heraus aufrufen

SubEthaEdit ist ein wunderbarer Editor mit vielen Features, aber eines fehlt: Die Möglichkeit, bequem externe Werkzeuge aufzurufen. In letzter Zeit bin ich ein Fan von PerlTidy geworden. Mit dem folgenden AppleScript kann man PerlTidy bequem über das Skript-Menü aufrufen. Es ersetzt den Text des aktiven Dokuments. Ist mal etwas schief gegangen, macht ⌘Z die Änderungen rückgängig.

tell application "SubEthaEdit"
	set pt to "-ce -bar -vtc=2 -pt=2 -sbt=2 -bt=2 -wba=\"? : .\""
	if the number of documents > 0 then
		set doc_text to the text of document 1 as string
		
		set f_perltidy_in to "/tmp/perltidy.in"
		
		try
			do shell script "rm " & f_perltidy_in & " "
		end try
		
		set f_in to open for access (f_perltidy_in as POSIX file) ¬
			with write permission
		try
			write doc_text to f_in
			close access f_in
		on error
			close access f_in
			return
		end try
		
		set cmd to "perltidy " & pt & " < " & f_perltidy_in
		set output to do shell script cmd
		set the text of document 1 to output
	end if
end tell

Verfasst von crenz um 05.05.05 20:47

Trackback-Pings

TrackBack-URL zu diesem Eintrag:
http://christian.web42.com/mt/mt-tb.cgi/4