«

»

Erlang ships with a quite nice Erlang mode for Emacs. Editing Erlang code is actually the only thing I ever use Emacs for.

Setting it up is only slightly painful. For a default R11B-3 installation your .emacs will look like this:

(setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.5.3/emacs" load-path)) (setq erlang-root-dir "/usr/local/lib/erlang") (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path)) (require 'erlang-start) (defvar inferior-erlang-prompt-timeout t)

The first set of expressions sets up Emacs to find erlang.el and the path to your Erlang installation.

The second expression tells the emacs mode not to wait for an Erlang prompt. This is my only annoyance with the mode. Without this defvar, when you send a command from Emacs to Erlang it'll hang for 60 seconds (or until you hit Ctrl-G) if there was any IO since the last prompt (e.g. an error_logger report or an io:format call). The caveat with this setting is that the first command you issue (the one that causes the inferior shell to get started) will get sent before Erlang is started and get lost. Issuing the first command twice is a small price to pay in this case, because the lock-up is annoying as all hell when you're in the middle of the compile/play cycle.

Using the Erlang mode is pretty straightforward. Tab does the right thing for indentation and is a good way to check to see if your code makes sense syntactically. If it doesn't indent to the right place, you probably screwed up. The electric stuff like comma and semicolon are great and save you a good deal of typing. The only command I really use is C-c C-k which compiles and reloads the current module into the running Erlang inferior shell. It will start one if one isn't already running (C-c C-z just starts the shell).

The other gripe I have is that when you get compiler errors sometimes clicking the line numbers takes you to the wrong line in the source file, but that's a relatively minor annoyance for me. Restarting seems to fix that (until it breaks again) and normally I'm not fighting too many compiler errors :)