andrewheiss / SublimeStataEnhanced

Plugin that adds support for Stata 11–15 for Sublime Text 2 and 3
55 stars 22 forks source link

Build doesn't work when .do files are set to open with application other than Stata #9

Closed alexwarofka closed 10 years ago

alexwarofka commented 10 years ago

Pretty much as the subject says, if Stata is not set as the default application for opening .do files (e.g. Sublime Text is instead), the build system is broken as a result of the "tell Finder to open" syntax used in the AppleScript. I've fixed it on my system as below.

In Stata.sublime-build, the section

{
  "selector": "source.stata",
  "cmd": ["osascript", 
          "-e", "try",
          "-e", "tell application \"Finder\" to activate & open POSIX file \"$file\"",
          "-e", "end try"]
}

could be replaced with:

{
  "selector": "source.stata",
  "cmd": ["osascript", 
          "-e", "try",
          "-e", "tell application \"StataMP\" to activate & DoCommandAsync \"do \\\"$file\\\"\"",
          "-e", "end try"]
}

Might be a good idea to pull in the Stata application name from the settings file, but I'm not immediately sure how to do this...

andrewheiss commented 10 years ago

Yeah, this is a problem with Stata 11 and 12. If the do file doesn't open via Finder, Stata won't run it. The build file used to be like you suggested before I added 11/12 support. I toyed with using build variants for 11/12 and 13, but it would still be complicated since people would have to manually change the Stata name.

I would love to have a setting for the Stata application name (I already have a place for it in the .sublime-settings file, but those variables unfortunately seem to only work in Python files, not in .sublime-build files.