└── emacs-client-mac.scpt /emacs-client-mac.scpt: -------------------------------------------------------------------------------- 1 | tell application "Terminal" 2 | try 3 | -- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't 4 | set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'" 5 | if frameVisible is not "t" then 6 | -- there is a not a visible frame, launch one 7 | do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n" 8 | end if 9 | on error 10 | -- daemon is not running, start the daemon and open a frame 11 | do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon" 12 | do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n" 13 | end try 14 | end tell 15 | 16 | -- bring the visible frame to the front 17 | tell application "Emacs" to activate --------------------------------------------------------------------------------