1erlang.el(3)               Erlang Module Definition               erlang.el(3)
2
3
4

NAME

6       erlang.el - Erlang mode for Emacs
7

DESCRIPTION

9       Possibly  the most important feature of an editor designed for program‐
10       mers is the ability to indent a line of code  in  accordance  with  the
11       structure of the programming language. The Erlang mode does, of course,
12       provide this feature. The layout used is based on the common use of the
13       language.  The  mode also provides things as syntax highlighting, elec‐
14       tric commands, module  name  verification,  comment  support  including
15       paragraph filling, skeletons, tags support etc.
16
17       In  the  following descriptions the use of the word Point means: "Point
18       can be seen as the position of the cursor. More precisely, the point is
19       the  position between two characters while the cursor is drawn over the
20       character following the point".
21

INDENT

23       The following command are directly available for indentation.
24
25         * TAB (erlang-indent-command) - Indents the current line of code.
26
27         * M-C-\ (indent-region) - Indents all lines in the region.
28
29         * M-l (indent-for-comment) - Insert a comment character to the  right
30           of the code on the line (if any).
31
32       Lines containing comment are indented differently depending on the num‐
33       ber of %-characters used:
34
35         * Lines with one %-character is indented to the right  of  the  code.
36           The  column is specified by the variable comment-column, by default
37           column 48 is used.
38
39         * Lines with two %-characters will be indented to the same  depth  as
40           code would have been in the same situation.
41
42         * Lines with three of more %-characters are indented to the left mar‐
43           gin.
44
45         * C-c C-q (erlang-indent-function) - Indents the current Erlang func‐
46           tion.
47
48         * M-x erlang-indent-clause RET
49            -Indent the current Erlang clause.
50
51         * M-x erlang-indent-current-buffer RET - Indent the entire buffer.
52

EDIT - FILL COMMENT

54       When  editing  normal  text in text mode you can let Emacs reformat the
55       text by the fill-paragraph command. This command will not work for com‐
56       ments since it will treat the comment characters as words.
57
58       The  Erlang editing mode provides a command that knows about the Erlang
59       comment structure and can be used to fill text paragraphs in  comments.
60       Ex:
61
62             %% This is   just a very simple test to show
63             %% how the Erlang fill
64             %% paragraph   command works.
65
66       Clearly,  the text is badly formatted. Instead of formatting this para‐
67       graph line by line, let's try erlang-fill-paragraph  by  pressing  M-q.
68       The result is:
69
70             %% This is just a very simple test to show how the Erlang fill
71             %% paragraph command works.
72

EDIT - COMMENT/UNCOMMENT REGION

74       C-c  C-c will put comment characters at the beginning of all lines in a
75       marked region. If you want to have two comment  characters  instead  of
76       one you can do C-u 2 C-c C-c
77
78       C-c C-u will undo a comment-region command.
79

EDIT - MOVING THE MARKER

81         * C-a M-a  (erlang-beginning-of-function) - Move the point to the be‐
82           ginning of the current or preceding Erlang function.  With  an  nu‐
83           meric argument (ex C-u 2 C-a M-a) the function skips backwards over
84           this many Erlang functions. Should the  argument  be  negative  the
85           point  is  moved  to  the beginning of a function below the current
86           function.
87
88         * M-C-a  (erlang-beginning-of-clause) - As above but  move  point  to
89           the beginning of the current or preceding Erlang clause.
90
91         * C-a  M-e  (erlang-end-of-function) - Move to the end of the current
92           or following Erlang function. With an numeric argument (ex C-u 2 C-
93           a  M-e)  the  function  skips backwards over this many Erlang func‐
94           tions. Should the argument be negative the point is  moved  to  the
95           end of a function below the current function.
96
97         * M-C-e   (erlang-end-of-clause) - As above but move point to the end
98           of the current or following Erlang clause.
99

EDIT - MARKING

101         * C-c M-h (erlang-mark-function) - Put the region around the  current
102           Erlang  function. The point is placed in the beginning and the mark
103           at the end of the function.
104
105         * M-C-h  (erlang-mark-clause) Put the region around the  current  Er‐
106           lang  clause.  The point is placed in the beginning and the mark at
107           the end of the function.
108

EDIT - FUNCTION HEADER COMMANDS

110         * C-c C-j (erlang-generate-new-clause) - Create a new clause  in  the
111           current  Erlang function. The point is placed between the parenthe‐
112           ses of the argument list.
113
114         * C-c C-y (erlang-clone-arguments) - Copy the function  arguments  of
115           the preceding Erlang clause. This command is useful when defining a
116           new clause with almost the same argument as the preceding.
117

EDIT - ARROWS

119         * C-c C-a (erlang-align-arrows) - aligns arrows after clauses  inside
120           a region.
121
122                 Example:
123
124                 sum(L) -> sum(L, 0).
125                 sum([H|T], Sum) -> sum(T, Sum + H);
126                 sum([], Sum) -> Sum.
127
128                 becomes:
129
130                 sum(L)          -> sum(L, 0).
131                 sum([H|T], Sum) -> sum(T, Sum + H);
132                 sum([], Sum)    -> Sum.
133

SYNTAX HIGHLIGHTING

135       The  syntax  highlighting  can be activated from the Erlang menu. There
136       are four different alternatives:
137
138         * Off: Normal black and white display.
139
140         * Level 1:  Function  headers,  reserved  words,  comments,  strings,
141           quoted atoms, and character constants will be colored.
142
143         * Level  2: The above, attributes, Erlang bif:s, guards, and words in
144           comments enclosed in single quotes will be colored.
145
146         * Level 3: The above, variables, records, and macros will be colored.
147           (This level is also known as the Christmas tree level.)
148

TAGS

150       For  the tag commands to work it requires that you have generated a tag
151       file. See Erlang mode users guide
152
153         * M-.  (find-tag) - Find a function definition. The default value  is
154           the function name under the point.
155
156         * Find  Tag  (erlang-find-tag)  - Like the Elisp-function `find-tag'.
157           Capable of retrieving Erlang modules. Tags  can  be  given  on  the
158           forms `tag', `module:', `module:tag'.
159
160         * M-+ (erlang-find-next-tag) - Find the next occurrence of tag.
161
162         * M-TAB (erlang-complete-tag) - Perform completion on the tag entered
163           in a tag search. Completes to the set of names listed in  the  cur‐
164           rent tags table.
165
166         * Tags aprops (tags-apropos) - Display list of all tags in tags table
167           REGEXP matches.
168
169         * C-x t s (tags-search) - Search through all files listed in tags ta‐
170           ble for match for REGEXP. Stops when a match is found.
171

SKELETONS

173       A skeleton is a piece of pre-written code that can be inserted into the
174       buffer. Erlang mode comes with  a  set  of  predefined  skeletons.  The
175       skeletons  can be accessed either from the Erlang menu of from commands
176       named tempo-template-erlang-*, as the skeletons is  defined  using  the
177       standard Emacs package "tempo". Here follows a brief description of the
178       available skeletons:
179
180         * Simple skeletons: If, Case, Receive, Receive After, Receive Loop  -
181           Basic code constructs.
182
183         * Header  elements:  Module,  Author - These commands insert lines on
184           the form -module(xxx).  and -author('my@home').. They can  be  used
185           directly,  but  are also used as part of the full headers described
186           below.
187
188         * Full Headers: Small (minimum requirement), Medium (with fields  for
189           basic  information  about  the  module),  and  Large Header (medium
190           header with some extra layout structure).
191
192         * Small Server - skeleton for a simple server not using OTP.
193
194         * Application - skeletons for the OTP application behavior
195
196         * Supervisor - skeleton for the OTP supervisor behavior
197
198         * Supervisor Bridge - skeleton for the OTP supervisor bridge behavior
199
200         * gen_server - skeleton for the OTP gen_server behavior
201
202         * gen_event - skeleton for the OTP gen_event behavior
203
204         * gen_fsm - skeleton for the OTP gen_fsm behavior
205
206         *
207            gen_statem (StateName/3) - skeleton for the OTP gen_statem  behav‐
208           ior using state name functions
209
210         *
211            gen_statem  (handle_event/4) - skeleton for the OTP gen_statem be‐
212           havior using one state function
213
214         * Library module - skeleton for a module that does  not  implement  a
215           process.
216
217         * Corba callback - skeleton for a Corba callback module.
218
219         * Erlang  test  suite - skeleton for a callback module for the erlang
220           test server.
221

SHELL

223         * New shell (erlang-shell) - Starts a new Erlang shell.
224
225         * C-c C-z, (erlang-shell-display ) - Displays  an  Erlang  shell,  or
226           starts a new one if there is no shell started.
227

COMPILE

229         * C-c  C-k, (erlang-compile) - Compiles the Erlang module in the cur‐
230           rent buffer. You can also use C-u C-c C-k to debug compile the mod‐
231           ule with the debug options debug_info and export_all.
232
233         * C-c C-l, (erlang-compile-display) - Display compilation output.
234
235         * C-u C-x` Start parsing the compiler output from the beginning. This
236           command will place the point on the line where the first error  was
237           found.
238
239         * C-x` (erlang-next-error) - Move the point on to the next error. The
240           buffer displaying the compilation errors will be  updated  so  that
241           the current error will be visible.
242

MAN

244       On  unix  you  can view the manual pages in emacs. In order to find the
245       manual pages, the variable `erlang-root-dir' should  be  bound  to  the
246       name  of  the  directory  containing  the Erlang installation. The name
247       should not include the final slash. Practically, you should add a  line
248       on the following form to your ~/.emacs,
249
250             (setq erlang-root-dir "/the/erlang/root/dir/goes/here")
251

STARTING IMENU

253         * M-x  imenu-add-to-menubar  RET - This command will create the IMenu
254           menu containing all the functions in the current buffer.The command
255           will  ask  you  for  a suitable name for the menu. Not supported by
256           Xemacs.
257

VERSION

259         * M-x erlang-version RET - This command displays the  version  number
260           of  the  Erlang editing mode. Remember to always supply the version
261           number when asking questions about the Erlang mode.
262
263Ericsson AB                       tools 3.5.1                     erlang.el(3)
Impressum