Yeah that's what I've been trying for, but the lack of the shebang one in
the dictionary is the problem.

on documentWillSave(myDoc)
    on menu_click(mList)
        local appName, topMenu, r

        -- Validate our input
        if mList's length < 3 then error "Menu list is not long enough"

        -- Set these variables for clarity and brevity later on
        set {appName, topMenu} to (items 1 through 2 of mList)
        set r to (items 3 through (mList's length) of mList)

        -- This overly-long line calls the menu_recurse function with
        -- two arguments: r, and a reference to the top-level menu
        tell application "System Events" to my menu_click_recurse(r,
((process appName)'s ¬
            (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
    end menu_click

    on menu_click_recurse(mList, parentObject)
        local f, r

        -- `f` = first item, `r` = rest of items
        set f to item 1 of mList
        if mList's length > 1 then set r to (items 2 through (mList's
length) of mList)

        -- either actually click the menu item, or recurse again
        tell application "System Events"
            if mList's length is 1 then
                click parentObject's menu item f
            else
                my menu_click_recurse(r, (parentObject's (menu item f)'s
(menu f)))
            end if
        end tell
    end menu_click_recurse

tell application "BBEdit" to activate
menu_click({"BBEdit", "#!", "Check Syntax"})
end documentWillSave

Is the closest (and other variants) I've gotten, but the problem is the
menu is grayed out, so it's not really a functional script.

I'm hoping somebody has a better idea.

-Brandon


On Sat, Apr 13, 2019 at 3:04 PM @lbutlr <[email protected]> wrote:

> On 13 Apr 2019, at 12:26, Brandon Schneider <[email protected]>
> wrote:
> > The idea is I want to run the #! command Check Syntax *before* a file
> saves (on its contents), and if there's an error, do not save. I've been
> able to achieve something close to this with calling external binaries, but
> I'd rather use the builtins of BBEdit.
>
> Attach a script to the save action.
>
> Bottom of page 309, then check page 31 for where to put them.
>
> But I don't know how you run the check syntax as it's not in the
> AppleScript dictionary (it is, but it is the HTML check syntax, not the
> shebang one).
>
>
> --
> You know what they say about paradigms:  Shift happens.
>
>
> --
> This is the BBEdit Talk public discussion group. If you have a
> feature request or need technical support, please email
> "[email protected]" rather than posting to the group.
> Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "BBEdit Talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/bbedit/D5tO4hanw_A/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://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