2 ## this scirpt works together with Quicksilver
3 ## copy/link this file to ~/Library/Application Support/Quicksilver/Action
4 ## and set a toggle event on Quicksilver preference
6 ## http://brettterpstra.com/2011/01/22/quick-tip-applescript-application-toggle/
9 #Version 1.0 toggle emacs front
11 set appName to "Emacs"
13 tell application "System Events"
14 if not (exists process appName) then
16 else if frontmost of process appName then
17 set visible of process appName to false
19 set frontmost of process appName to true
23 tell application appName to activate
26 ## version 2.0 - using emacs daemon and client
27 ##set appName to "Emacs"
28 ##set startIt to false
29 ##tell application "System Events"
31 ## -- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't
32 ## set frameVisible to do shell script "/usr/local/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'"
33 ## if frameVisible is not "t" then
34 ## -- there is a not a visible frame, launch one
35 ## do shell script "/usr/local/bin/emacsclient -c -n"
36 ## set startIt to true
37 ## else if frontmost of process "Emacs" then
38 ## set visible of process "Emacs" to false
40 ## set frontmost of process "Emacs" to true
43 ## -- daemon is not running, start the daemon and open a frame
44 ## do shell script "/usr/local/bin/emacs --daemon"
45 ## do shell script "/usr/local/bin/emacsclient -c -n"
46 ## set startIt to true
50 ##-- bring the visible frame to the front
52 ## tell application "Emacs" to activate