Skip to content

Instantly share code, notes, and snippets.

@caldwell
Last active June 24, 2018 19:46
Show Gist options
  • Save caldwell/5026506 to your computer and use it in GitHub Desktop.
Save caldwell/5026506 to your computer and use it in GitHub Desktop.
I put this in my ~/bin and then `alias emacs='ec'`
#!/bin/sh
which osascript > /dev/null 2>&1 && osascript -e 'tell application "Emacs" to activate'
emacsclient -c "$@"
@house9
Copy link

house9 commented Oct 31, 2013

following instructions from: http://emacsformacosx.com/tips
running mtn lion OS X 10.8.5
receive the error:

emacsclient: invalid option -- c
Try `emacsclient --help' for more information

testing $ emacsclient --help

Usage: emacsclient [OPTIONS] FILE...
Tell the Emacs server to visit the specified files.
Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.

The following OPTIONS are accepted:

-V, --version       Just print version info and return
-H, --help          Print this usage information message
-e, --eval          Evaluate FILE arguments as Lisp expressions
-n, --no-wait       Don't wait for the server to return
-d, --display=DISPLAY   Visit the file in the given display
-s, --socket-name=FILENAME
            Set filename of the UNIX socket for communication
-f, --server-file=FILENAME
            Set filename of the TCP authentication file
-a, --alternate-editor=EDITOR
            Editor to fallback to if server is not running

Report bugs to bug-gnu-emacs@gnu.org.

This is on Version 24.3 (9.0), Note that it does launch emacs anyhow

@hovsater
Copy link

hovsater commented Nov 5, 2013

Am I missing something? Will not osascript -e 'tell application "Emacs" to activate' just activate Emacs? Must not Emacs be started with the --daemon flag in order for emacsclient to connect to it?

@suranap
Copy link

suranap commented Feb 15, 2014

I believe you can use -a with an empty string to active emacs: emacsclient -c -a "" "$@". I just make an alias instead of a script.

@caldwell
Copy link
Author

@house9: Looks like you're running /usr/bin/emacsclient which is the one shipped by Apple and is really old. You need to run the emacsclient that comes with Emacs (Emacs.app/Contents/MacOS/bin/emacsclient).

@unknownzerx
Copy link

I've got a joke

alias emcas=emacs
alias emasc=emacs

Copy link

ghost commented Jun 24, 2018

FYI, re: "emacsclient -c ..."

-c is not a valid option on the emacsclient shipped in the DMG.

See https://gist.github.com/caldwell/5026506#gistcomment-941485, above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment