Created
October 16, 2016 04:33
-
-
Save hadongsoo/8ce386f7654074e185f9def4fd394931 to your computer and use it in GitHub Desktop.
emacs for daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Terminal" | |
try | |
-- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't | |
set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'" | |
if frameVisible is not "t" then | |
-- there is a not a visible frame, launch one | |
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n" | |
end if | |
on error | |
-- daemon is not running, start the daemon and open a frame | |
do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon" | |
do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n" | |
end try | |
end tell | |
-- bring the visible frame to the front | |
tell application "Emacs" to activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment