Skip to content

Instantly share code, notes, and snippets.

@kdheepak
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdheepak/9e287b937edb2509eab9 to your computer and use it in GitHub Desktop.
Save kdheepak/9e287b937edb2509eab9 to your computer and use it in GitHub Desktop.
Applescript for EmacsClient.app
on run {input}
try
set emacs_client_path to "usr/local/bin/"
set pathtofile to quoted form of POSIX path of input
set frameVisible to do shell script emacs_client_path & "emacsclient -e '(<= 2 (length (visible-frame-list)))'"
if frameVisible is "t" then
do shell script emacs_client_path & "emacsclient -n " & pathtofile
else
-- there is a not a visible frame, launch one
do shell script emacs_client_path & "emacsclient -c -n " & pathtofile
end if
on error
set emacs_client_path to "usr/local/bin/"
do shell script emacs_client_path & "emacsclient -c -n "
end try
-- bring the visible frame to the front
tell application "Emacs" to activate
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment