.TH erlang.el 3erl "tools 3.4.3" "Ericsson AB" "Erlang Module Definition" .SH NAME erlang.el \- Erlang mode for Emacs .SH DESCRIPTION .LP Possibly the most important feature of an editor designed for programmers is the ability to indent a line of code in accordance with the structure of the programming language\&. The Erlang mode does, of course, provide this feature\&. The layout used is based on the common use of the language\&. The mode also provides things as syntax highlighting, electric commands, module name verification, comment support including paragraph filling, skeletons, tags support etc\&. .LP In the following descriptions the use of the word \fIPoint\fR\& means: "Point can be seen as the position of the cursor\&. More precisely, the point is the position between two characters while the cursor is drawn over the character following the point"\&. .SH "INDENT" .LP The following command are directly available for indentation\&. .RS 2 .TP 2 * \fI\fITAB\fR\&\fR\& (\fIerlang-indent-command\fR\&) - Indents the current line of code\&. .LP .TP 2 * \fI\fIM-C-\\\fR\&\fR\& (\fIindent-region\fR\&) - Indents all lines in the region\&. .LP .TP 2 * \fI\fIM-l\fR\&\fR\& (\fIindent-for-comment\fR\&) - Insert a comment character to the right of the code on the line (if any)\&. .LP .RE .LP Lines containing comment are indented differently depending on the number of %-characters used: .RS 2 .TP 2 * Lines with one %-character is indented to the right of the code\&. The column is specified by the variable \fIcomment-column\fR\&, by default column 48 is used\&. .LP .TP 2 * Lines with two %-characters will be indented to the same depth as code would have been in the same situation\&. .LP .TP 2 * Lines with three of more %-characters are indented to the left margin\&. .LP .TP 2 * \fI\fIC-c C-q\fR\&\fR\& (\fIerlang-indent-function\fR\&) - Indents the current Erlang function\&. .LP .TP 2 * \fI\fIM-x erlang-indent-clause RET\fR\&\fR\& .br -Indent the current Erlang clause\&. .LP .TP 2 * \fI\fIM-x erlang-indent-current-buffer RET\fR\&\fR\& - Indent the entire buffer\&. .LP .RE .SH "EDIT - FILL COMMENT " .LP When editing normal text in text mode you can let Emacs reformat the text by the \fIfill-paragraph\fR\& command\&. This command will not work for comments since it will treat the comment characters as words\&. .LP The Erlang editing mode provides a command that knows about the Erlang comment structure and can be used to fill text paragraphs in comments\&. Ex: .LP .nf %% This is just a very simple test to show %% how the Erlang fill %% paragraph command works. .fi .LP Clearly, the text is badly formatted\&. Instead of formatting this paragraph line by line, let\&'s try \fIerlang-fill-paragraph\fR\& by pressing \fI\fIM-q\fR\&\fR\&\&. The result is: .LP .nf %% This is just a very simple test to show how the Erlang fill %% paragraph command works. .fi .SH "EDIT - COMMENT/UNCOMMENT REGION " .LP \fI\fIC-c C-c\fR\&\fR\& will put comment characters at the beginning of all lines in a marked region\&. If you want to have two comment characters instead of one you can do \fI\fIC-u 2 C-c C-c\fR\&\fR\& .LP \fI\fIC-c C-u\fR\&\fR\& will undo a comment-region command\&. .SH "EDIT - MOVING THE MARKER " .RS 2 .TP 2 * \fI\fIC-a M-a \fR\&\fR\& (\fIerlang-beginning-of-function\fR\&) - Move the point to the beginning of the current or preceding Erlang function\&. With an numeric argument (ex \fI\fIC-u 2 C-a M-a\fR\&\fR\&) the function skips backwards over this many Erlang functions\&. Should the argument be negative the point is moved to the beginning of a function below the current function\&. .LP .TP 2 * \fI\fIM-C-a \fR\&\fR\& (\fIerlang-beginning-of-clause\fR\&) - As above but move point to the beginning of the current or preceding Erlang clause\&. .LP .TP 2 * \fI\fIC-a M-e \fR\&\fR\& (\fIerlang-end-of-function\fR\&) - Move to the end of the current or following Erlang function\&. With an numeric argument (ex \fI\fIC-u 2 C-a M-e\fR\&\fR\&) the function skips backwards over this many Erlang functions\&. Should the argument be negative the point is moved to the end of a function below the current function\&. .LP .TP 2 * \fI\fIM-C-e \fR\&\fR\& (\fIerlang-end-of-clause\fR\&) - As above but move point to the end of the current or following Erlang clause\&. .LP .RE .SH "EDIT - MARKING " .RS 2 .TP 2 * \fI\fIC-c M-h\fR\&\fR\& (\fIerlang-mark-function\fR\&) - Put the region around the current Erlang function\&. The point is placed in the beginning and the mark at the end of the function\&. .LP .TP 2 * \fI\fIM-C-h \fR\&\fR\& (\fIerlang-mark-clause\fR\&) Put the region around the current Erlang clause\&. The point is placed in the beginning and the mark at the end of the function\&. .LP .RE .SH "EDIT - FUNCTION HEADER COMMANDS " .RS 2 .TP 2 * \fI\fIC-c C-j\fR\&\fR\& (\fIerlang-generate-new-clause\fR\&) - Create a new clause in the current Erlang function\&. The point is placed between the parentheses of the argument list\&. .LP .TP 2 * \fI\fIC-c C-y\fR\&\fR\& (\fIerlang-clone-arguments\fR\&) - Copy the function arguments of the preceding Erlang clause\&. This command is useful when defining a new clause with almost the same argument as the preceding\&. .LP .RE .SH "EDIT - ARROWS" .RS 2 .TP 2 * \fI\fIC-c C-a\fR\&\fR\& (\fIerlang-align-arrows\fR\&) - aligns arrows after clauses inside a region\&. .LP .nf Example: sum(L) -> sum(L, 0). sum([H|T], Sum) -> sum(T, Sum + H); sum([], Sum) -> Sum. becomes: sum(L) -> sum(L, 0). sum([H|T], Sum) -> sum(T, Sum + H); sum([], Sum) -> Sum. .fi .LP .RE .SH "SYNTAX HIGHLIGHTING" .LP The syntax highlighting can be activated from the Erlang menu\&. There are four different alternatives: .RS 2 .TP 2 * Off: Normal black and white display\&. .LP .TP 2 * Level 1: Function headers, reserved words, comments, strings, quoted atoms, and character constants will be colored\&. .LP .TP 2 * Level 2: The above, attributes, Erlang bif:s, guards, and words in comments enclosed in single quotes will be colored\&. .LP .TP 2 * Level 3: The above, variables, records, and macros will be colored\&. (This level is also known as the Christmas tree level\&.) .LP .RE .SH "TAGS" .LP For the tag commands to work it requires that you have generated a tag file\&. See Erlang mode users guide .LP .RS 2 .TP 2 * \fI\fIM-\&. \fR\&\fR\& (\fIfind-tag\fR\&) - Find a function definition\&. The default value is the function name under the point\&. .LP .TP 2 * Find Tag (\fIerlang-find-tag\fR\&) - Like the Elisp-function `find-tag\&'\&. Capable of retrieving Erlang modules\&. Tags can be given on the forms `tag\&', `module:\&', `module:tag\&'\&. .LP .TP 2 * \fI\fIM-+\fR\&\fR\& (\fIerlang-find-next-tag\fR\&) - Find the next occurrence of tag\&. .LP .TP 2 * \fI\fIM-TAB\fR\&\fR\& (\fIerlang-complete-tag\fR\&) - Perform completion on the tag entered in a tag search\&. Completes to the set of names listed in the current tags table\&. .LP .TP 2 * Tags aprops (\fItags-apropos\fR\&) - Display list of all tags in tags table REGEXP matches\&. .LP .TP 2 * \fI\fIC-x t s\fR\&\fR\& (\fItags-search\fR\&) - Search through all files listed in tags table for match for REGEXP\&. Stops when a match is found\&. .LP .RE .SH "SKELETONS" .LP A skeleton is a piece of pre-written code that can be inserted into the buffer\&. Erlang mode comes with a set of predefined skeletons\&. The skeletons can be accessed either from the Erlang menu of from commands named \fItempo-template-erlang-*\fR\&, as the skeletons is defined using the standard Emacs package "tempo"\&. Here follows a brief description of the available skeletons: .RS 2 .TP 2 * Simple skeletons: If, Case, Receive, Receive After, Receive Loop - Basic code constructs\&. .LP .TP 2 * Header elements: Module, Author - These commands insert lines on the form \fI-module(\fR\&xxx\fI)\&. \fR\& and \fI-author(\&'my@home\&')\&.\fR\&\&. They can be used directly, but are also used as part of the full headers described below\&. .LP .TP 2 * Full Headers: Small (minimum requirement), Medium (with fields for basic information about the module), and Large Header (medium header with some extra layout structure)\&. .LP .TP 2 * Small Server - skeleton for a simple server not using OTP\&. .LP .TP 2 * Application - skeletons for the OTP application behavior .LP .TP 2 * Supervisor - skeleton for the OTP supervisor behavior .LP .TP 2 * Supervisor Bridge - skeleton for the OTP supervisor bridge behavior .LP .TP 2 * gen_server - skeleton for the OTP gen_server behavior .LP .TP 2 * gen_event - skeleton for the OTP gen_event behavior .LP .TP 2 * gen_fsm - skeleton for the OTP gen_fsm behavior .LP .TP 2 * gen_statem (StateName/3) - skeleton for the OTP gen_statem behavior using state name functions .LP .TP 2 * gen_statem (handle_event/4) - skeleton for the OTP gen_statem behavior using one state function .LP .TP 2 * Library module - skeleton for a module that does not implement a process\&. .LP .TP 2 * Corba callback - skeleton for a Corba callback module\&. .LP .TP 2 * Erlang test suite - skeleton for a callback module for the erlang test server\&. .LP .RE .SH "SHELL" .RS 2 .TP 2 * New shell (\fIerlang-shell\fR\&) - Starts a new Erlang shell\&. .LP .TP 2 * \fI\fIC-c C-z,\fR\&\fR\& (\fIerlang-shell-display \fR\&) - Displays an Erlang shell, or starts a new one if there is no shell started\&. .LP .RE .SH "COMPILE" .RS 2 .TP 2 * \fI\fIC-c C-k,\fR\&\fR\& (\fIerlang-compile\fR\&) - Compiles the Erlang module in the current buffer\&. You can also use \fI\fIC-u C-c C-k\fR\&\fR\& to debug compile the module with the debug options \fIdebug_info\fR\& and \fIexport_all\fR\&\&. .LP .TP 2 * \fI\fIC-c C-l,\fR\&\fR\& (\fIerlang-compile-display\fR\&) - Display compilation output\&. .LP .TP 2 * \fI\fIC-u C-x`\fR\&\fR\& Start parsing the compiler output from the beginning\&. This command will place the point on the line where the first error was found\&. .LP .TP 2 * \fI\fIC-x`\fR\&\fR\& (\fIerlang-next-error\fR\&) - Move the point on to the next error\&. The buffer displaying the compilation errors will be updated so that the current error will be visible\&. .LP .RE .SH "MAN" .LP On unix you can view the manual pages in emacs\&. In order to find the manual pages, the variable `erlang-root-dir\&' should be bound to the name of the directory containing the Erlang installation\&. The name should not include the final slash\&. Practically, you should add a line on the following form to your ~/\&.emacs, .LP .nf (setq erlang-root-dir "/the/erlang/root/dir/goes/here") .fi .SH "STARTING IMENU" .RS 2 .TP 2 * \fI\fIM-x imenu-add-to-menubar RET\fR\&\fR\& - This command will create the IMenu menu containing all the functions in the current buffer\&.The command will ask you for a suitable name for the menu\&. Not supported by Xemacs\&. .LP .RE .SH "VERSION" .RS 2 .TP 2 * \fI\fIM-x erlang-version RET\fR\&\fR\& - This command displays the version number of the Erlang editing mode\&. Remember to always supply the version number when asking questions about the Erlang mode\&. .LP .RE