On 26 Jan 2014, at 00:59, Tim Hill <[email protected]> wrote:
> Just finished a text filter (in Lua) that cleans up source files for me
> (mostly comment formatting). Works great :)
>
> However, if the filter does nothing (that is, the output text is the same as
> the input text), BBEdit always marks the document as dirty, even though
> nothing has changed. While this is ok, it would be nice to avoid this (as it
> also indicates to the user if the filter did anything or not).
I don't think there is any way of avoiding this with a text filter.
What you could do is get and set the text using AppleScript and make your
modifications to it using your chosen scripting language--Perl in this example:
tell application "BBEdit" to tell the front document
set _text to its text
set _new_text to do shell script "perl <<END;
while (<DATA>) {
# make modifications
print;
};
__DATA__
" & _text & return & "
END
" -- *
if _text is not _new_text then
set its text to _new_text
else
beep
end if
end tell
-- * check whether the final return is necessary!
JD
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].