Lots of people seem to wonder, "what is the best emacs for macOS"?
Their criteria for "best" being not always clear, the answer I systematically give is: "Clone the repository and build it yourself. This is free software!"
Since I always forget the dependencies and the steps, this page is a memo for myself, and for curious people who want to try themselves.
Note: I am not a programmer. I just follow instructions. There is nothing magic in the 8 instruction lines that follow. Before, or after you've cloned emacs, you can read the INSTALL.REPO
file where basically everything I write here is found, along with the README
and the INSTALL
files where you'll find additional or redundant information. It's basically all there. I am not making this up.
The dependencies below are the minimum emacs requires, and you can find them by running ./autogen.sh
first and then ./configure
yourself before using brew to install them: the two scripts will just choke every time they don't find the required libraries.
What I did to come up with that list is just add dependencies until the scripts ran their course without error.
If this is your first "development" attempt, you will need the XCode command line tools, basically because you'll need gcc
and git
for the whole process.
brew
will prompt you about that during its install process, and even if that does not happen, the first time you run git
, for example to clone emacs, macOS will tell you that you need to install them and prompt you with a nice dialog.
The required dependencies are the following:
Autoconf
texinfo
GNU Mailutils
GnuTLS
I sent the link to this article to the emacs-devel
mailing list for verification and Pankaj Jangid was nice enough to tell me about his own experiences and suggested a list of non-required but recommended packages that emacs would notice during the configuration process. Alan Third, the ns-port maintainer, also chimed in to indicate that some of Pankaj proposed libraries were in fact ignored since the image types they correspond to are handled by macOS proper.
The recomended dependencies are the following:
librsvg
libxpm
lcms2
jansson
If you want to install the above recommended dependencies, you'll need to add a brew install
instruction as shown below.
# install brew
# URL: https://brew.sh/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# install required dependencies
# or jump to "configure, etc." below and install them one by onebrew install autoconf texinfo gnutls mailutils
# install recommended dependencies, but only after you've checked what they do by following the links above...brew install librsvg libxpm lcms2 jansson
# clone emacs
# URL: https://savannah.gnu.org/projects/emacsgit clone -b master git://git.sv.gnu.org/emacs.git
# configure, build and install emacscd emacs
./autogen.sh
./configure
make install
Et voilà! Emacs.app
now resides in emacs/nextstep/Emacs.app
.
I don't suppose you'd want to install emacs from scratch without knowing how to use it, but if that's the case, and that's totally OK, emacs comes with thousands of pages of manuals that are just a ctrl-h i
away.
That shortcut means hit the control
key, hold it pressed, hit the h
key, release both, and hit the i
key. That shortcut calls the info
function, which bring up the list of manuals included in emacs.
You can also start a tutorial with ctrl-h t
, which means hit the control
key, hold it pressed, hit the h
key, release both, and hit the t
key. That shortcut calls the help-with-tutorial
function.
The manuals are online, if you feel more confortable reading in a web browser: GNU Emacs Manuals Online
If you need to use emacs
from the command line you may need to update your .profile
file with aliases like this:
alias emacs='path/to/emacs/nextstep/Emacs.app/Contents/MacOS/Emacs'
alias emacsclient='path/to/emacs/nextstep/Emacs.app/Contents/MacOS/bin/emacsclient'
alias ctags='path/to/emacs/nextstep/Emacs.app/Contents/MacOS/bin/ctags'
alias ebrowse='path/to/emacs/nextstep/Emacs.app/Contents/MacOS/bin/ebrowse'
alias etags='path/to/emacs/nextstep/Emacs.app/Contents/MacOS/bin/etags'
and that's basically it.
The first time you build emacs, along with installing all the dependencies, etc. might take some time, maybe a good 30 minutes, maybe more. But then, you end up with a configuration where you just need to update the code once in a while, and make install
the thing again to have the latest version running.
Basically, all is needed is to run this:
# inside the cloned emacs directory
# update the codegit pull
# build and install the new versionmake install
And the next time to start emacs, you run the lastest master
branch code.
The whole point of Free Software is that is gives you the tools necessary to understand what is going on, to learn how to do things yourself and to control your environement.
So, yes, emacs is free software, and now you're all set to play with the code and do your own thing, that will eventually lead to first contribute small things, and then bigger and bigger things to emacs proper.
For that, you just need to create your own development branch and code there:
# inside the cloned emacs directory
# update the code, just to have the latest onegit pull
# create your development/test branch, for example "myEmacs"git checkout -b myEmacs
# open that new branch in Finderopen .
Everything you do there will never impact the master
branch from which you have built emacs. You can always git checkout master
back to go back to a clean slate (git
will eventually ask you to git stash
away your modifications before switching to master
, so just follow the instructions).
Now, you may want to know a bit more about Emacs Lisp, about git
, about how to contribute to emacs, so here are some references:
ctrl-h i
to find the list of manuals available right at your finger tips) and also online: git
comes with excellent documentation, and a free book too: ctrl-h i
away, but it is also online: help-gnu-emacs
list and for development help there is the emacs-devel
list, along with a lot of other emacs related lists, hosted on the emacs development site: