aliquot

< a quantity that can be divided into another a whole number of time />

GNU Emacs on OS X 10.7

June 16, 2012

I have been using Aquamacs for over 5 or 6 years now, but I recently decided to go back to a simpler version of Emacs, namely the latest build of Emacs for OS X.

Why? There are several reasons:

Everything started with my looking at the overtone project (following a post mirrored on Planet Clojure). There's a nice screencast on the Github website, and I also found this one:

So basically, the author customized his emacs with a lot of add-ons, especially to assist coding activity: auto-complete, snippets, connection to various REPLs, etc. I wanted to do the same, but without using the complete overtone configuration files. That's almost done!

Be sure to grab one of the 24.* series in the build repository. I personally choose the 24.1-rc pretest version. I haven't had any problem so far.

To configure ELPA, we can add the following two lines in our .emacs:

(setq package-archives
      '(("marmalade" . "http://marmalade-repo.org/packages/")
        ("tromey" . "http://tromey.com/elpa/")))

This will add Marmalade as well as Tromey ELPA to the default GNU repository. Something that's really important is to configure the keyboard; in order to exchange command the option () and command () keys, I just added

(setq mac-option-modifier 'none)

Otherwise, we cannot type symbols like ~ (Alt-n), or use square brackets (which is pretty sad when writing R code :-). Other customizations can be added, for example to make the connection with Mac pbpaste more transparent.

I was aware of Yasnippet, which is inspired from Textmate, but I just gave it a try in the past. Now, I'm using it and it seems the trigger key () is not too intrusive when I'm typing.

I am also trying to familiarize myself with ido-mode that I've never used:

(require 'ido) 
(ido-mode t)

My first impressions were disconcerting, but now I seem to get used to it. I just have to remember that I now have to C-d to get into dired-mode for browsing content of a directory.

My .emacs is not entirely clean at the moment: I need to investigate the autoload vs. require issue more carefully. For the moment, I am quite happy with the configuration of Lisp, Clojure, R, and Python. I can connect to Slime using either lein swank or M-x clojure-jack-in from within Emacs. For R, I have Yasnippets working right out of the box, together with other goodies from ESS. I was previously using the Stata ado-mode, but ess-mode provides most of the basic functionalities I need for interacting with Stata.

An example of an interactive R session is shown below:

Emacs 1

Top panel shows how Yasnippet prompting tool is triggered when pressing tab (), while bottom panel shows available arguments when typing rnorm in the R shell directly.

Here is another screenshot which show the beginning of a clojure script with auto-completion and a running lein shell (left), and one (right) with two buffers with Yasnippet providing basic construction of a defn in Clojure (top), or suggesting methods in Python mode (bottom). :

Finally, this configuration works equally well when Emacs run in a Terminal (nw), as can be seen below:

Emacs 4

apple emacs

See Also

» Emacs versus Textmate » Work distraction-free OS X desktop » The random joys of living with a Macbook » Playing With Docbook Again » Apple weekend miscellanies