Depending on how your versions of emacs were built, there are two different procedures.
If you built an OS X app (Emacs.app), all you should need to do is drag the app to the trash. All of emacs' support files are contained withing the app
If you just have an emacs binary sitting around, you need to delete that and the corresponding support files. For instance, the emacs binary that comes with OS X is in /usr/bin/emacs
, and its support files are in /usr/share/emacs
. The contents of the second directory should contain subdirs named site-lisp
and named after version numbers (e.g., 22.1). If you want to be complete, you might want to search your disk for directories named site-lisp
to make sure you found everything.
As a side note, the version of emacs that is available through MacPorts now seems to be pretty good. I've been using it for a while, and haven't had any major issues.
To make Emacs.app open files in an existing frame instead of a new frame, add (setq ns-pop-up-frames nil)
to a configuration file like ~/.emacs
.
You can open a file from a terminal with open -a emacs file
or emacsclient -n file
. If Emacs.app is not open but there is an Emacs --daemon
process, for some reason emacsclient -n file
doesn't work but emacsclient -nc file
does.
Make sure you use the emacsclient
binary included with the version of Emacs you use, like /Applications/Emacs.app/Contents/MacOS/bin/emacsclient
, or /usr/local/bin/emacsclient
if you installed Emacs with Homebrew.
To start an Emacs server at login, for example save this plist as ~/Library/LaunchAgents/my.emacsdaemon.plist
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.emacsdaemon</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Emacs.app/Contents/MacOS/Emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/> <!-- run the program again if it terminates -->
</dict>
</plist>
The plist is loaded automatically the next time you login, but you can load it immediately by running launchctl load ~/Library/LaunchAgents/my.emacsdaemon.plist
.
Edit: I still don't know why people are associating file types with an AppleScript application instead of just Emacs.app. The script in kuzzooroo's answer could also be written as a shell script though:
macos=/Applications/Emacs.app/Contents/MacOS
if pgrep -qf 'Emacs.*--daemon'; then
[[ $($macos/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))') = t ]] && args=-nc || args=-n
else
$macos/Emacs --daemon
args=-nc
fi
$macos/bin/emacsclient $args "$@"
open -a /Applications/Emacs.app
You can use Platypus to save the script as an application:
I just started using Emacs, but I have a completely different setup. I made my own Emacs application by making a copy of iTerm.app, changing the CFBundleIdentifier in the Info.plist so that the application uses a different preference file, and setting the default command to /usr/local/bin/emacs
. I have added (server-start)
to ~/.emacs
and I open the custom Emacs application at login. I used Platypus to create an application that runs emacsclient -n "$@";open -b my.emacs
and I made it the default application for text files.
Best Answer
Aliases are a shell-specific concept, so bash aliases don't carry over to eshell. Eshell has its own alias system, documented in comments near the top of
em-alias.el
. In a nutshell, you define aliases with thealias
commands, and they are stored automatically for future sessions. The syntax is not the same asbash
, for example you would writealias l='ls -l $*'
in eshell where you writealias ls='ls -l'
in bash. Alias definitions live in a file called~/.eshell/alias
where"~/.eshell"
is the value ofeshell-directory-name
.Eshell also has a shell function system, documented in comments near the top of
esh-cmd.el
. Quoting the first paragraph: