X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Femacs_toggle.applescript;fp=scripts%2Femacs_toggle.applescript;h=f034a4e95185508c11770f8c32d4448febc1d1e5;hb=5df35baa55cdad0cb6b0fc70fb2ff512bc2bfe9c;hp=d3bbe3b1ca541255cf0b41762912c75e4b33da2a;hpb=5a883339d74021115be65ab7f3ad71ba2ab6ff76;p=dotfiles.git diff --git a/scripts/emacs_toggle.applescript b/scripts/emacs_toggle.applescript index d3bbe3b..f034a4e 100644 --- a/scripts/emacs_toggle.applescript +++ b/scripts/emacs_toggle.applescript @@ -1,10 +1,27 @@ +#tell application "System Events" +# tell application process "Emacs" +# if visible then +# set visible to false +# else +# set visible to true +# tell application "Emacs" to activate +# end if +# end tell +#end tell +# +## http://brettterpstra.com/2011/01/22/quick-tip-applescript-application-toggle/ +set appName to "Emacs" +set startIt to false tell application "System Events" - tell application process "Emacs" - if visible then - set visible to false - else - set visible to true - tell application "Emacs" to activate - end if - end tell + if not (exists process appName) then + set startIt to true + else if frontmost of process appName then + set visible of process appName to false + else + set frontmost of process appName to true + end if end tell +if startIt then + tell application appName to activate +end if +