Emacs I: Introduction and Installation

November 8th, 2008

A (very) Brief Background

So emacs is one of those programs that never dies.. it just looks that way. Development for emacs began in the 70’s and is still active, making it somewhat of a big deal in terms of computer history. Emacs stands for Editor MACroS and was originally designed for some archaic system I’ve never heard of. If you’re really that interested, check out the wikipedia entry. The plural form of emacs is emacsen. There is a very popular fork of emacs called Xemacs, which forked in 1991 apparently due to emacs’s glacial release cycle. Enough about that.. On to the important stuff.

Choosing an Emacs

There are an absolute ton of emacsen to choose from. They range from platform dependant to cross platform and in a hundred other variations. For this series, I’ll be using CarbonEmacs which is a version specifically designed for OS X and is based on GNU Emacs 22.3. It offers quite a few features I don’t use and only one I do. (My META key is my cmd key.) mac-keys-mode, for instance, makes tutorials and such hard to follow. Just learn the emacs way and it will feel much easier when you need to use emacs on a different platform. From what I understand the main difference to an emacs newbie between Xemacs and GNU Emacs, is Xemacs offers more net-installable packages. This isn’t such a big deal as I’ll show you how to install packages later in the post.

Installing your Emacs

Installation of your emacs will differ depending on which one you chose. For me, I just opened a DMG and moved into my apps directory. You may need to compile yours from source, so here’s a handy link on how to do that.

How to Install a package

Package installation is pretty much at the core of extending emacs. There are a few possibilities in how you may need to install a particular package and I’ve outlined those below.

A very important thing to stick with at the start is your directory structure. I changed mine a week or so into my emacs journey and it introduced some errors I didn’t quite know how to fix. I have one .emacs file that lives at ~/.emacs, a symlink of ~/.emacs.d/dot-emacs (for version control purposes), which mostly calls my configuration files which do all of the actual heavy lifting. I keep my emacs related things in my .emacs.d folder also located in my home folder. Beneath that, I have a folder named configs which holds package specific dependencies. You can take a look at my emacs folder at my github repo.

Install via Make Install

Those packages that have a make install option are by far the easiest to install. The biggest hurdle is figuring out where those packages are going and adding it to your load path. You can find the actual location of where things are being installed by looking at the output of your make install command. For me, make install adds packages to /usr/local/share/emacs/site-lisp and the syntax for adding a location to your loadpath is:

(setq load-path (cons "/usr/local/share/emacs/site-lisp" load-path))

Install via Copying files over

For a few files, such as django-html-mode, installation is as simple as copying the relevant .el to somewhere on your load path. For me, this is just ~/.emacs.d/ but I would imagine that it will eventually get put in a folder with other things like it.

Install via Make

This is the biggest pain among the 3 installation methods. Its typically used for packages that are rather large. js2-mode, for instance, uses this method. It effectively involves byte-compiling your elisp and sticking it a directory on your load path. I really don’t like to pollute my load path too much, but I haven’t found a way around this yet. Open to suggestions if any emacs gurus happen across this post. The method for byte-compiling is typically `make` but can sometimes vary. Be sure to read the INSTALL doc in the package you download for the correct instructions.

Well that bascially concludes the basic installation post. Be sure to check out everyone else doing the post-a-day marathon: Greg Newman, Eric Florenzano, Brian Rosner, James Tauber and Eric Holsher.


Comments are disabled. If that bothers you, please contact me on twitter at @justinlilly and let me know.