O'Reilly logo

Building Web Applications with Erlang by Zachary Kessin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D. Using Erlang with Emacs

For many Erlang developers, the editor of choice is Emacs. As a longtime Emacs user I have found there to be many reasons for this.

One feature of the Emacs Erlang mode is that you can compile a file by typing “C-c C-k”, which will open Erlang in a shell and compile the buffer you are in. You can also copy and paste code from a buffer to an Erlang shell.

Being able to copy and paste code from a buffer to the Erlang REPL makes it very easy to explore solutions to a problem. The programmer can create a simple module and load it into Erlang with “C-c C-k”, then create a bunch of test cases that are copied via standard Emacs editing to the shell to ensure that the code is working correctly. This does not replace formal testing, but supplements it when doing development.

In addition, the Erlang mode has a set of templates that can be used to create common structures. So if you need to work with the OTP gen_server pattern, you can generate the skeleton of that structure by opening up a new buffer and selecting the correct structure. The template for gen_server is shown in Example D-3 at the end of this chapter.

Note

Erlang comes with a very nice Erlang mode. You can find more details on it at http://www.erlang.org/doc/apps/tools/erlang_mode_chapter.html.

Distel

If you want to have a powerful interface between Emacs and Erlang, check out Distel mode. Distel (short for Distributed Emacs Lisp) extends Emacs Lisp to be able to speak to an Erlang node in a way ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required