On 08/23/2018, at 13:39, Rich Siegel <[email protected] 
<mailto:[email protected]>> wrote:
> On 8/23/18 at 2:06 PM, [email protected] <mailto:[email protected]> (TJ Luoma) 
> wrote:
> 
>> *set* docList *to* (*documents* *whose* on disk *is* *true* *and* modified
>> *is* *true*)
> 
> I recommend that you use "text documents" here, in order to avoid unintended 
> consequences.


Hey Rich,

I left that broad intentionally, because TJ didn't specify he wanted to avoid 
same, nevertheless you're probably right.  :)


I mostly use text documents and shell worksheets myself.

Where do you see the most likelihood of unintended consequences occurring?


One could take safety a step further and require an Auto-Save-ON setting in the 
document to be saved.

----------------------------------------------------------------

tell application "BBEdit"
    
    set docList to (documents whose on disk is true and modified is true)
    
    repeat with theDoc in docList
        try
            if (contents of lines 1 thru 5 of theDoc) contains "Auto-Save-ON" 
then
                save theDoc
            end if
        end try
    end repeat
    
end tell

----------------------------------------------------------------

I'm limiting the “header text” to the first 5 lines above, but that's easily 
adjusted.

One could automate the emplacement of the auto-save-setting:

----------------------------------------------------------------

tell application "BBEdit"
    tell front text document
        tell (first line whose contents is "")
            set its contents to "# Auto-Save-ON" & linefeed
        end tell
    end tell
end tell

----------------------------------------------------------------

One could check the doc-type and use the appropriate comment character for that 
type.

Many things are possible with BBEdit and a little bit of AppleScript.

--
Take Care,
Chris

-- 
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].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to