The purpose of this user guide is to introduce you to the
Erlang mode for Emacs and gives some relevant background
information of the functions and features. See also
Basic knowledge of Emacs and Erlang/OTP.
There are two Elsip modules include in this tool package for Emacs. There is erlang.el that defines the actual erlang mode and there is erlang-start.el that makes some nice initializations.
To set up the Erlang Emacs mode on a UNIX systems, edit/create
the file
Below is a complete example of what should be added to a user's
/emacs"
load-path))
(setq erlang-root-dir "/usr/local/otp")
(setq exec-path (cons "/usr/local/otp/bin" exec-path))
(require 'erlang-start)
]]>
To set up the Erlang Emacs mode on a Windows systems,
edit/create the file
Below is a complete example of what should be added to a user's
/lib/tools-/emacs"
load-path))
(setq erlang-root-dir "C:/Program Files/erl")
(setq exec-path (cons "C:/Program Files/erl/bin" exec-path))
(require 'erlang-start)
]]>
In .emacs, the slash character "/" can be used as path separator. But if you decide to use the backslash character "\\", please not that you must use double backslashes, since they are treated as escape characters by Emacs.
The "Oxford Advanced Learners Dictionary of Current English" says the following about the word "indent":
"start (a line of print or writing) farther from the margin than the others".
The Erlang mode does, of course, provide this feature. The layout used is based on the common use of the language.
It is strongly recommend to use this feature and avoid to indent lines in a nonstandard way. Some motivations are:
The indentation features can be used to reindent large sections of a file. If some lines use nonstandard indentation they will be reindented.
When the Erlang mode is correctly installed, it is
automatically activated when a file ending in
When a file is saved the name in the
An "electric" command is a character that in addition to just inserting the character performs some type of action. For example the ";" character is typed in a situation where is ends a function clause a new function header is generated. The electric commands are as follows:
To disable all electric commands set the variable
(setq erlang-electric-commands '())
It is possible for Emacs to use colors when displaying a buffer. By "syntax highlighting", we mean that syntactic components, for example keywords and function names, will be colored.
The basic idea of syntax highlighting is to make the structure of a program clearer. For example, the highlighting will make it easier to spot simple bugs. Have not you ever written a variable in lower-case only? With syntax highlighting a variable will colored while atoms will be shown with the normal text color.
Tags is a standard Emacs package used to record information about source files in large development projects. In addition to listing the files of a project, a tags file normally contains information about all functions and variables that are defined. By far, the most useful command of the tags system is its ability to find the definition of functions in any file in the project. However the Tags system is not limited to this feature, for example, it is possible to do a text search in all files in a project, or to perform a project-wide search and replace.
In order to use the Tags system a file named
The
As seen in the help text -- unless you have not upgraded your
Emacs yet (well, what are you waiting around here for? Off you go and
upgrade!) --
Basically, the
etags file1.erl file2.erl
This will create a file named
The
find . -name "*.[he]rl" -print | etags -
The above line will create a
Please see the GNU Emacs Manual and the etags man page for more info.
The look and feel on an Erlang shell inside Emacs should be the same as in a normal Erlang shell. There is just one major difference, the cursor keys will actually move the cursor around just like in any normal Emacs buffer. The command line history can be accessed by the following commands:
If the Erlang shell buffer would be killed the command line history is saved to a file. The command line history is automatically retrieved when a new Erlang shell is started.
The classic edit-compile-bugfix cycle for Erlang is to edit the source file in an editor, save it to a file and switch to an Erlang shell. In the shell the compilation command is given. Should the compilation fail you have to bring out the editor and locate the correct line.
With the Erlang editing mode the entire edit-compile-bugfix cycle can be performed without leaving Emacs. Emacs can order Erlang to compile a file and it can parse the error messages to automatically place the point on the erroneous lines.