3
votes

I want to create a command line executable which will spawn an emacs window/application. I searched on the internet and found that the emacs shipped with Mac is not supported in X11 window So, I downloaded the latest emacs from http://emacsformacosx.com/ and installed it in my mac.
Then I go to the /usr/bin directory and create a symbolic link like this:

sudo ln /Applications/Emacs.app/Contents/MacOS/Emacs xemacs

when I run this symblolic link by ./xemacs it says(. means /usr/bin):

Warning: arch-dependent data dir (/Users/david/src/emacs-dev/ftp-versions/emacs-24.2/nextstep/Emacs.app/Contents/MacOS//libexec/emacs/24.2/x86_64-apple-darwin/) does not exist. Warning: arch-independent data dir (/Users/david/src/emacs-dev/ftp-versions/emacs-24.2/nextstep/Emacs.app/Contents/Resources/share/emacs/24.2/etc/) does not exist. Error: charsets directory not found: /Users/david/src/emacs-dev/ftp-versions/emacs-24.2/nextstep/Emacs.app/Contents/Resources/share/emacs/24.2/etc/charsets Emacs will not function correctly without the character map files. Please check your installation!

But if I run the Emacs binary in directory /Applications/Emacs.app/Contents/MacOS/ it starts the application without any error.

Any one knows how to solve this problem?

2
I imagine it examines argv[0] to find its resources. You might have to use a script instead of a symlink. - tripleee
By the by, xemacs in general refers to a fork project, not GNU Emacs. For your own private use, this is completely harmless, of course, but I thought I'd still point out the potential for a mix-up. - tripleee
... Or, symlink to /Applications/Emacs.app? Why do you want a symlink, anyway; isn't Emacs in your PATH? - tripleee
@tripleee Emacs.app is a directory. “emacs” is taken by Mac-shipped version of emacs. Sure I can add the /Applications/Emacs.app/Contents/MacOS/ to PATH, but I hate type Capital Emacs :( - Peiti Li
If it is only the capital letter, you could use an alias: alias emacs="open -a Emacs" - Matthias

2 Answers

3
votes

Up to this point I think the best way is to create an executable script under /usr/bin which will execute the binary file /Applications/Emacs.app/Contents/MacOS/Emacs. The reason I didn't use "open" command is that I need to use some Emacs binary arguments. Compared to "open" this method can spawn multiple instance of emacs.

The script is :

#! /bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$@"

Then make it executable by doing chmod +x script.sh

then make the symlink

ln -s "/usr/local/bin/script.sh" /usr/local/bin/xemacs

2
votes

You could use an alias: alias emacs="open -a Emacs --args <youroptions>. The option --args allows you to pass options directly to emacs (e.g., -q avoids the evaluation of the init script).