]> code.delx.au - gnu-emacs/blob - man/programs.texi
Minor clarifications. Explain how to use imenu-sort-function.
[gnu-emacs] / man / programs.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985,86,87,93,94,95,97,99,00,2001 Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions.
4 @node Programs, Building, Text, Top
5 @chapter Editing Programs
6 @cindex Lisp editing
7 @cindex C editing
8 @cindex program editing
9
10 Emacs provides many features to facilitate editing programs. These
11 features can:
12
13 @itemize @bullet
14 @item
15 Find or move over top-level definitions (@pxref{Defuns}).
16 @item
17 Apply the usual indentation conventions of the language
18 (@pxref{Program Indent}).
19 @item
20 Insert, kill or align comments (@pxref{Comments}).
21 @item
22 Balance parentheses (@pxref{Parentheses}).
23 @item
24 Highlight program syntax (@pxref{Font Lock}).
25 @end itemize
26
27 @menu
28 * Program Modes:: Major modes for editing programs.
29 * Defuns:: Commands to operate on major top-level parts
30 of a program.
31 * Program Indent:: Adjusting indentation to show the nesting.
32 * Comments:: Inserting, killing, and aligning comments.
33 * Parentheses:: Commands that operate on parentheses.
34 * Documentation:: Getting documentation of functions you plan to call.
35 * Hideshow:: Displaying blocks selectively.
36 * Symbol Completion:: Completion on symbol names of your program or language.
37 * Glasses:: Making identifiersLikeThis more readable.
38 * Misc for Programs:: Other Emacs features useful for editing programs.
39 * C Modes:: Special commands of C, C++, Objective-C,
40 Java, and Pike modes.
41 * Fortran:: Fortran mode and its special features.
42 * Asm Mode:: Asm mode and its special features.
43 @end menu
44
45 @node Program Modes
46 @section Major Modes for Programming Languages
47 @cindex modes for programming languages
48
49 Emacs has specialized major modes for various programming languages.
50 @xref{Major Modes}. A programming language major mode typically
51 specifies the syntax of expressions, the customary rules for
52 indentation, how to do syntax highlighting for the language, and how
53 to find the beginning of a function definition. They often provide
54 facilities for compiling and debugging programs as well.
55
56 Ideally, Emacs should provide a major mode for each programming
57 language that you might want to edit; if it doesn't have a mode for
58 your favorite language, you can contribute one. But often the mode
59 for one language can serve for other syntactically similar languages.
60 The major mode for language @var{l} is called @code{@var{l}-mode},
61 and you can enable it by typing @kbd{M-x @var{l}-mode @key{RET}}.
62 @xref{Choosing Modes}.
63
64 @cindex Perl mode
65 @cindex Icon mode
66 @cindex Awk mode
67 @cindex Makefile mode
68 @cindex Tcl mode
69 @cindex CPerl mode
70 @cindex DSSSL mode
71 @cindex Octave mode
72 @cindex Metafont mode
73 @cindex Modula2 mode
74 @cindex Prolog mode
75 @cindex Simula mode
76 @cindex VHDL mode
77 @cindex M4 mode
78 @cindex Shell-script mode
79 @cindex Delphi mode
80 @cindex PostScript mode
81 The existing programming language major modes include Lisp, Scheme (a
82 variant of Lisp) and the Scheme-based DSSSL expression language, Ada,
83 Awk, C, C++, Delphi (Object Pascal), Fortran (free format and fixed
84 format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s
85 companion for font creation), Modula2, Objective-C, Octave, Pascal,
86 Perl, Pike, PostScript, Prolog, Simula, Tcl, and VHDL. There is
87 also a major mode for makefiles, called Makefile mode. An alternative
88 mode for Perl is called CPerl mode. Modes are available for the
89 scripting languages of the common Unix shells, VMS DCL, and
90 MS-DOS/MS-Windows @samp{BAT} files. There are also major modes for
91 editing various sorts of configuration files.
92
93 @kindex DEL @r{(programming modes)}
94 @findex c-electric-backspace
95 In most programming languages, indentation should vary from line to
96 line to illustrate the structure of the program. So the major modes
97 for program languages arrange for @key{TAB} to update the indentation
98 of the current line. They also rebind @key{DEL} to treat a tab as if
99 it were the equivalent number of spaces. This makes it possible to
100 reduce indentation one column at a time without worrying whether it is
101 made up of spaces or tabs. Use @kbd{C-b C-d} to delete a tab
102 character before point, in these modes.
103
104 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
105 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL
106 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
107 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}).
108
109 @cindex mode hook
110 @vindex c-mode-hook
111 @vindex lisp-mode-hook
112 @vindex emacs-lisp-mode-hook
113 @vindex lisp-interaction-mode-hook
114 @vindex scheme-mode-hook
115 Turning on a major mode runs a normal hook called the @dfn{mode
116 hook}, which is the value of a Lisp variable. Each major mode has a
117 mode hook, and the hook's name is always made from the mode command's
118 name by adding @samp{-hook}. For example, turning on C mode runs the
119 hook @code{c-mode-hook}, while turning on Lisp mode runs the hook
120 @code{lisp-mode-hook}. The purpose of the mode hook is to give you a
121 place to set up customizations for that major mode. @xref{Hooks}.
122
123 @node Defuns
124 @section Top-Level Definitions, or Defuns
125
126 In Emacs, a major definition at the top level in the buffer is
127 called a @dfn{defun}. The name comes from Lisp, but in Emacs we use
128 it for all languages.
129
130 In most programming language modes, Emacs assumes that a defun is
131 any pair of parentheses (or braces, if the language uses braces this
132 way) that starts at the left margin. For example, in C, the body of a
133 function definition is normally a defun, because the open-brace that
134 begins it is normally at the left margin. A variable's initializer
135 can also count as a defun, if the open-brace that begins the
136 initializer is at the left margin.
137
138 However, some language modes provide their own code for recognizing
139 defuns in a way that suits the language syntax and conventions better.
140
141 @menu
142 * Left Margin Paren:: An open-paren or similar opening delimiter
143 starts a defun if it is at the left margin.
144 * Moving by Defuns:: Commands to move over or mark a major definition.
145 * Imenu:: Making buffer indexes as menus.
146 * Which Function:: Which Function mode shows which function you are in.
147 @end menu
148
149 @node Left Margin Paren
150 @subsection Left Margin Convention
151
152 @cindex open-parenthesis in leftmost column
153 @cindex ( in leftmost column
154 In most major modes, Emacs assumes that any opening delimiter found
155 at the left margin is the start of a top-level definition, or defun.
156 Therefore, @strong{never put an opening delimiter at the left margin
157 unless it should have that significance.} For instance, never put an
158 open-parenthesis at the left margin in a Lisp file unless it is the
159 start of a top-level list. Never put an open-brace or other opening
160 delimiter at the beginning of a line of C code unless it is at top
161 level.
162
163 If you don't follow this convention, not only will you have trouble
164 when you explicitly use the commands for motion by defuns; other
165 features that use them will also give you trouble. This includes
166 the indentation commands (@pxref{Program Indent}) and Font Lock
167 mode (@pxref{Font Lock}).
168
169 The most likely problem case is when you want an opening delimiter
170 at the start of a line inside a string. To avoid trouble, put an
171 escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some
172 other Lisp dialects) before the opening delimiter. This will not
173 affect the contents of the string, but will prevent that opening
174 delimiter from starting a defun. Here's an example:
175
176 @example
177 (insert "Foo:
178 \(bar)
179 ")
180 @end example
181
182 In the earliest days, the original Emacs found defuns by moving
183 upward a level of parentheses or braces until there were no more
184 levels to go up. This always required scanning all the way back to
185 the beginning of the buffer, even for a small function. To speed up
186 the operation, we changed Emacs to assume that any opening delimiter
187 at the left margin is the start of a defun. This heuristic is nearly
188 always right, and avoids the need to scan back to the beginning of the
189 buffer. However, it mandates following the convention described
190 above.
191
192 @node Moving by Defuns
193 @subsection Moving by Defuns
194 @cindex defuns
195
196 These commands move point or set up the region based on top-level
197 major definitions, also called @dfn{defuns}.
198
199 @table @kbd
200 @item C-M-a
201 Move to beginning of current or preceding defun
202 (@code{beginning-of-defun}).
203 @item C-M-e
204 Move to end of current or following defun (@code{end-of-defun}).
205 @item C-M-h
206 Put region around whole current or following defun (@code{mark-defun}).
207 @end table
208
209 @cindex move to beginning or end of function
210 @cindex function, move to beginning or end
211 @kindex C-M-a
212 @kindex C-M-e
213 @kindex C-M-h
214 @findex beginning-of-defun
215 @findex end-of-defun
216 @findex mark-defun
217 The commands to move to the beginning and end of the current defun
218 are @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e}
219 (@code{end-of-defun}). If you repeat one of these commands, or use a
220 positive numeric argument, each repetition moves to the next defun in
221 the direction of motion.
222
223 @kbd{C-M-a} with a negative argument @minus{}@var{n} moves forward
224 @var{n} times to the next beginning of a defun. This is not exactly
225 the same place that @kbd{C-M-e} with argument @var{n} would move to;
226 the end of this defun is not usually exactly the same place as the
227 beginning of the following defun. (Whitespace, comments, and perhaps
228 declarations can separate them.) Likewise, @kbd{C-M-e} with a
229 negative argument moves back to an end of a defun, which is not quite
230 the same as @kbd{C-M-a} with a positive argument.
231
232 @kindex C-M-h @r{(C mode)}
233 @findex c-mark-function
234 To operate on the current defun, use @kbd{C-M-h} (@code{mark-defun})
235 which puts point at the beginning and mark at the end of the current
236 defun. This is the easiest way to get ready to kill the defun in
237 order to move it to a different place in the file. If you use the
238 command while point is between defuns, it uses the following defun.
239
240 In C mode, @kbd{C-M-h} runs the function @code{c-mark-function},
241 which is almost the same as @code{mark-defun}; the difference is that
242 it backs up over the argument declarations, function name and returned
243 data type so that the entire C function is inside the region.
244 @xref{Marking Objects}. This is an example of how major modes adjust
245 the standard key bindings so that they do their standard jobs in a way
246 better fitting a particular language. Other major modes may adjust
247 any or all of these key bindings for that purpose.
248
249 @node Imenu
250 @subsection Imenu
251 @cindex indexes of buffer contents
252 @cindex buffer content indexes
253 @cindex tags
254
255 The Imenu facility offers a way to find the the major definitions in
256 a file by name. It is also useful in text formatter major modes,
257 where it treats each chapter, section, etc., as a definition.
258 (@pxref{Tags}, for a more powerful feature that handles multiple files
259 together.)
260
261 @findex imenu
262 If you type @kbd{M-x imenu}, it reads the name of a definition using
263 the minibuffer, then goes to that definition. You can use completion
264 to specify the name, and a complete list of possible names is always
265 displayed.
266
267 @findex imenu-add-menubar-index
268 Alternatively, you can bind the command @code{imenu} to a mouse
269 click. Then it displays mouse menus for you to select the definition
270 you want. You can also add the buffer's index to the menu bar by
271 calling @code{imenu-add-menubar-index}. If you want to have this
272 menu bar item available for all buffers in a certain major mode, you
273 can do this by adding @code{imenu-add-menubar-index} to its mode
274 hook. But then you will have to wait for the buffer to be searched
275 for definitions, each time you visit a file which uses that mode.
276
277 @vindex imenu-auto-rescan
278 When you change the contents of a buffer, if you add or delete
279 definitions, you can update the buffer's index to correspond to the
280 new contents by invoking the @samp{*Rescan*} item in the menu.
281 Rescanning happens automatically if @code{imenu-auto-rescan} is
282 non-@code{nil}. There is no need to rescan because of small changes
283 in the text.
284
285 @vindex imenu-sort-function
286 You can customize the way the menus are sorted by setting the
287 variable @code{imenu-sort-function}. By default names are ordered as
288 they occur in the buffer; if you want alphabetic sorting, use the
289 symbol @code{imenu--sort-by-name} as the value. You can also
290 define your own comparison function by writing Lisp code.
291
292 Imenu provides the information to guide Which Function mode
293 @ifnottex
294 (@pxref{Which Function}).
295 @end ifnottex
296 @iftex
297 (see below).
298 @end iftex
299 The Speedbar can also use it (@pxref{Speedbar}).
300
301 @node Which Function
302 @subsection Which Function Mode
303
304 Which Function mode is a minor mode that displays the current
305 function name in the mode line, updating it as you move around in a
306 buffer.
307
308 @findex which-function-mode
309 @vindex which-func-modes
310 To enable (or disable) Which Function mode, use the command @kbd{M-x
311 which-function-mode}. This command is global; it applies to all
312 buffers, both existing ones and those yet to be created. However, this
313 only affects certain major modes, those listed in the value of
314 @code{which-func-modes}. If the value is @code{t}, then Which Function
315 mode applies to all major modes that know how to support it---which are
316 the major modes that support Imenu.
317
318 @node Program Indent
319 @section Indentation for Programs
320 @cindex indentation for programs
321
322 The best way to keep a program properly indented is to use Emacs to
323 reindent it as you change it. Emacs has commands to indent properly
324 either a single line, a specified number of lines, or all of the lines
325 inside a single parenthetical grouping.
326
327 @menu
328 * Basic Indent:: Indenting a single line.
329 * Multi-line Indent:: Commands to reindent many lines at once.
330 * Lisp Indent:: Specifying how each Lisp function should be indented.
331 * C Indent:: Extra features for indenting C and related modes.
332 * Custom C Indent:: Controlling indentation style for C and related modes.
333 @end menu
334
335 @cindex pretty-printer
336 Emacs also provides a Lisp pretty-printer in the library @code{pp}.
337 This program reformats a Lisp object with indentation chosen to look nice.
338
339 @node Basic Indent
340 @subsection Basic Program Indentation Commands
341
342 The basic indentation commands indent a single line according to the
343 usual conventions of the language you are editing.
344
345 @table @kbd
346 @item @key{TAB}
347 Adjust indentation of current line.
348 @item C-j
349 Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}).
350 @item @key{LINEFEED}
351 This key is a way to enter @kbd{C-j}, on some keyboards.
352 @end table
353
354 @kindex TAB @r{(programming modes)}
355 @findex c-indent-command
356 @findex indent-line-function
357 @findex indent-for-tab-command
358 The basic indentation command is @key{TAB}, which gives the current line
359 the correct indentation as determined from the previous lines. The
360 function that @key{TAB} runs depends on the major mode; it is
361 @code{indent-for-tab-command}
362 in Lisp mode, @code{c-indent-command} in C mode, etc. These functions
363 understand the syntax and conventions of different languages, but they all do
364 conceptually the same job: @key{TAB} in any programming-language major mode
365 inserts or deletes whitespace at the beginning of the current line,
366 independent of where point is in the line. If point was inside the
367 whitespace at the beginning of the line, @key{TAB} puts it at the end of
368 that whitespace; otherwise, @key{TAB} keeps point fixed with respect to
369 the characters around it.
370
371 Use @kbd{C-q @key{TAB}} to insert a tab at point.
372
373 @kindex C-j
374 @findex newline-and-indent
375 When entering lines of new code, use @kbd{C-j}
376 (@code{newline-and-indent}), which is equivalent to a @key{RET}
377 followed by a @key{TAB}. @kbd{C-j} at the end of a line creates a
378 blank line and then gives it the appropriate indentation.
379
380 @key{TAB} indents lines that start within a parenthetical grouping
381 each under the preceding line (or the text after the parenthesis).
382 Therefore, if you manually give one of these lines a nonstandard
383 indentation, the lines below will tend to follow it. This behavior is
384 convenient in cases where you have overridden the standard result of
385 @key{TAB} because you find it unaesthetic for a particular line.
386
387 Remember that an open-parenthesis, open-brace or other opening delimiter
388 at the left margin is assumed by Emacs (including the indentation routines)
389 to be the start of a function. Therefore, you must never have an opening
390 delimiter in column zero that is not the beginning of a function, not even
391 inside a string. This restriction is vital for making the indentation
392 commands fast; you must simply accept it. @xref{Left Margin Paren},
393 for more information on this.
394
395 Normally, lines are indented with tabs and spaces. If you want Emacs
396 to use spaces only, see @ref{Just Spaces}.
397
398 @node Multi-line Indent
399 @subsection Indenting Several Lines
400
401 When you wish to reindent several lines of code which have been
402 altered or moved to a different level in the parenthesis structure,
403 you have several commands available.
404
405 @table @kbd
406 @item C-M-q
407 Reindent all the lines within one parenthetical grouping(@code{indent-sexp}).
408 @item C-u @key{TAB}
409 Shift an entire parenthetical grouping rigidly sideways so that its
410 first line is properly indented.
411 @item C-M-\
412 Reindent all lines in the region (@code{indent-region}).
413 @item M-x indent-code-rigidly
414 Shift all the lines in the region rigidly sideways, but do not alter
415 lines that start inside comments and strings.
416 @end table
417
418 @kindex C-M-q
419 @findex indent-sexp
420 You can reindent the contents of a single parenthetical grouping by
421 positioning point before the beginning of it and typing @kbd{C-M-q}
422 (@code{indent-sexp} in Lisp mode, @code{c-indent-exp} in C mode; also
423 bound to other suitable commands in other modes). The indentation of
424 the line where the grouping starts is not changed; therefore, this
425 changes only the relative indentation within the grouping, not its
426 overall indentation. To correct that as well, type @key{TAB} first.
427
428 @kindex C-u TAB
429 If you like the relative indentation within a grouping, but not the
430 indentation of its first line, you can type @kbd{C-u @key{TAB}} to
431 reindent the whole grouping as a rigid unit. @key{TAB} with a numeric
432 argument reindents the current line as usual, then reindents by the
433 same amount all the lines in the parenthetical grouping starting on
434 the current line. It is clever, though, and does not alter lines that
435 start inside strings, or C preprocessor lines when in C mode.
436
437 @findex indent-code-rigidly
438 Another way to specify the range to be reindented is with the region.
439 The command @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to
440 every line whose first character is between point and mark. The command
441 @kbd{M-x indent-code-rigidly} rigidly shifts all the lines in the region
442 sideways, like @code{indent-rigidly} does (@pxref{Indentation
443 Commands}), except that it doesn't alter the indentation of lines that
444 start inside a comment or a string, unless the region starts inside that
445 comment or string.
446
447 @node Lisp Indent
448 @subsection Customizing Lisp Indentation
449 @cindex customizing Lisp indentation
450
451 The indentation pattern for a Lisp expression can depend on the function
452 called by the expression. For each Lisp function, you can choose among
453 several predefined patterns of indentation, or define an arbitrary one with
454 a Lisp program.
455
456 The standard pattern of indentation is as follows: the second line of the
457 expression is indented under the first argument, if that is on the same
458 line as the beginning of the expression; otherwise, the second line is
459 indented underneath the function name. Each following line is indented
460 under the previous line whose nesting depth is the same.
461
462 @vindex lisp-indent-offset
463 If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides
464 the usual indentation pattern for the second line of an expression, so that
465 such lines are always indented @code{lisp-indent-offset} more columns than
466 the containing list.
467
468 @vindex lisp-body-indent
469 Certain functions override the standard pattern. Functions whose
470 names start with @code{def} treat the the second lines as the start of
471 a @dfn{body}, by indenting the second line @code{lisp-body-indent}
472 additional columns beyond the open-parenthesis that starts the
473 expression.
474
475 You can override the standard pattern in various ways for individual
476 functions, according to the @code{lisp-indent-function} property of the
477 function name. There are four possibilities for this property:
478
479 @table @asis
480 @item @code{nil}
481 This is the same as no property---use the standard indentation pattern.
482 @item @code{defun}
483 Handle this function like a @samp{def} construct: treat the second
484 line the start of a @dfn{body}.
485 @item a number, @var{number}
486 The first @var{number} arguments of the function are
487 @dfn{distinguished} arguments; the rest are considered the body
488 of the expression. A line in the expression is indented according to
489 whether the first argument on it is distinguished or not. If the
490 argument is part of the body, the line is indented @code{lisp-body-indent}
491 more columns than the open-parenthesis starting the containing
492 expression. If the argument is distinguished and is either the first
493 or second argument, it is indented @emph{twice} that many extra columns.
494 If the argument is distinguished and not the first or second argument,
495 the line uses the standard pattern.
496 @item a symbol, @var{symbol}
497 @var{symbol} should be a function name; that function is called to
498 calculate the indentation of a line within this expression. The
499 function receives two arguments:
500 @table @asis
501 @item @var{state}
502 The value returned by @code{parse-partial-sexp} (a Lisp primitive for
503 indentation and nesting computation) when it parses up to the
504 beginning of this line.
505 @item @var{pos}
506 The position at which the line being indented begins.
507 @end table
508 @noindent
509 It should return either a number, which is the number of columns of
510 indentation for that line, or a list whose car is such a number. The
511 difference between returning a number and returning a list is that a
512 number says that all following lines at the same nesting level should
513 be indented just like this one; a list says that following lines might
514 call for different indentations. This makes a difference when the
515 indentation is being computed by @kbd{C-M-q}; if the value is a
516 number, @kbd{C-M-q} need not recalculate indentation for the following
517 lines until the end of the list.
518 @end table
519
520 @node C Indent
521 @subsection Commands for C Indentation
522
523 Here are special features for indentation in C mode and related modes:
524
525 @table @code
526 @item C-c C-q
527 @kindex C-c C-q @r{(C mode)}
528 @findex c-indent-defun
529 Reindent the current top-level function definition or aggregate type
530 declaration (@code{c-indent-defun}).
531
532 @item C-M-q
533 @kindex C-M-q @r{(C mode)}
534 @findex c-indent-exp
535 Reindent each line in the balanced expression that follows point
536 (@code{c-indent-exp}). A prefix argument inhibits error checking and
537 warning messages about invalid syntax.
538
539 @item @key{TAB}
540 @findex c-indent-command
541 Reindent the current line, and/or in some cases insert a tab character
542 (@code{c-indent-command}).
543
544 If @code{c-tab-always-indent} is @code{t}, this command always reindents
545 the current line and does nothing else. This is the default.
546
547 If that variable is @code{nil}, this command reindents the current line
548 only if point is at the left margin or in the line's indentation;
549 otherwise, it inserts a tab (or the equivalent number of spaces,
550 if @code{indent-tabs-mode} is @code{nil}).
551
552 Any other value (not @code{nil} or @code{t}) means always reindent the
553 line, and also insert a tab if within a comment, a string, or a
554 preprocessor directive.
555 @end table
556
557 To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This
558 first selects the whole buffer as the region, then reindents that
559 region.
560
561 To reindent the current block, use @kbd{C-M-u C-M-q}. This moves
562 to the front of the block and then reindents it all.
563
564 @node Custom C Indent
565 @subsection Customizing C Indentation
566 @cindex style (for indentation)
567
568 C mode and related modes use a simple yet flexible mechanism for
569 customizing indentation. The mechanism works in two steps: first it
570 classifies the line syntactically according to its contents and context;
571 second, it associates each kind of syntactic construct with an
572 indentation offset based on your selected @dfn{style}.
573
574 @table @kbd
575 @item M-x c-set-style @key{RET} @var{style} @key{RET}
576 Select predefined indentation style @var{style}.
577 @end table
578
579 A style is a named collection of indentation customizations that can
580 be used in C mode and the related modes. Emacs comes with several
581 predefined styles, including @code{gnu}, @code{k&r}, @code{bsd},
582 @code{stroustrup}, @code{linux}, @code{python}, @code{java},
583 @code{whitesmith}, @code{ellemtel}, @code{cc-mode}, and @code{user}.
584 Some of these styles are primarily intended for one language, but any
585 of them can be used with any of the languages supported by these
586 modes. To find out what a style looks like, select it and reindent
587 some code, e.g., by typing @key{C-M-q} at the start of a function
588 definition.
589
590 @findex c-set-style
591 To choose a style for the current buffer, use the command @kbd{M-x
592 c-set-style}. Specify a style name as an argument (case is not
593 significant). This command affects the current buffer only, and it
594 affects only future invocations of the indentation commands; it does
595 not change the indentation of the code in the buffer. To reindent the
596 whole buffer in the new style, you can type @kbd{C-x h C-M-\}.
597
598 @vindex c-default-style
599 You can also set the variable @code{c-default-style} to specify the
600 default style for various major modes. Its value should be an alist,
601 in which each element specifies one major mode and which indentation
602 style to use for it. For example,
603
604 @example
605 (setq c-default-style
606 '((java-mode . "java") (other . "gnu")))
607 @end example
608
609 @noindent
610 specifies an explicit choice for Java mode, and the default @samp{gnu}
611 style for the other C-like modes. This variable takes effect when you
612 switch to one of the C-like major modes; thus, if you specify a new
613 default style for Java mode, you can make it take effect in an
614 existing Java mode buffer by typing @kbd{M-x java-mode} there.
615
616 The @code{gnu} style specifies the formatting recommended by the GNU
617 Project for C; it is the default, so as to encourage use of our
618 recommended style.
619
620 @xref{Customizing Indentation,, cc-mode, the CC Mode Manual}, for
621 more information on customizing indentation for C and related modes,
622 including how to override parts of an existing style and how to define
623 your own styles.
624
625 @node Parentheses
626 @section Commands for Editing with Parentheses
627
628 @findex check-parens
629 @cindex unbalanced parentheses and quotes
630 This section describes the commands and features that take advantage
631 of the parenthesis structure in a program, or help you keep it
632 balanced.
633
634 When talking about these facilities, the term ``parenthesis'' also
635 includes braces, brackets, or whatever delimiters are defined to match
636 in pairs. This is controlled by the major mode, through the syntax
637 table (@pxref{Syntax}). In Lisp, only parentheses count; in C, these
638 commands apply to braces and brackets too.
639
640 You can use @kbd{M-x check-parens} to find any unbalanced
641 parentheses and unbalanced string quotes in the buffer.
642
643 @menu
644 * Expressions:: Expressions with balanced parentheses.
645 * Moving by Parens:: Commands for moving up, down and across
646 in the structure of parentheses.
647 * Matching:: Insertion of a close-delimiter flashes matching open.
648 @end menu
649
650 @node Expressions
651 @subsection Expressions with Balanced Parentheses
652
653 @cindex sexp
654 @cindex expression
655 @cindex balanced expression
656 These commands deal with balanced expressions, also called
657 @dfn{sexps}@footnote{The word ``sexp'' is used to refer to an
658 expression in Lisp.}.
659
660 @table @kbd
661 @item C-M-f
662 Move forward over a balanced expression (@code{forward-sexp}).
663 @item C-M-b
664 Move backward over a balanced expression(@code{backward-sexp}).
665 @item C-M-k
666 Kill balanced expression forward (@code{kill-sexp}).
667 @item C-M-@key{DEL}
668 Kill balanced expression backward (@code{backward-kill-sexp}).
669 @item C-M-t
670 Transpose expressions (@code{transpose-sexps}).
671 @item C-M-@@
672 Put mark after following expression (@code{mark-sexp}).
673 @end table
674
675 Each programming language major mode customizes the definition of
676 balanced expressions to suit that language. Balanced expressions
677 typically include symbols, numbers, and string constants, as well as
678 anything contained in parentheses, brackets or braces. Some languages
679 have obscure forms of expression syntax that nobody has bothered to
680 implement in Emacs.
681
682 @cindex Control-Meta
683 By convention, the keys for these commands are always Control-Meta
684 characters. They usually act like the corresponding Meta characters,
685 except that they take note of parentheses and their contents. For
686 instance, the command @kbd{C-M-b} moves backward over a balanced
687 expression, just as @kbd{M-b} moves back over a word.
688
689 @kindex C-M-f
690 @kindex C-M-b
691 @findex forward-sexp
692 @findex backward-sexp
693 To move forward over a balanced expression, use @kbd{C-M-f}
694 (@code{forward-sexp}). If the first significant character after point
695 is an opening delimiter (@samp{(} in Lisp; @samp{(}, @samp{[} or
696 @samp{@{} in C), @kbd{C-M-f} moves past the matching closing
697 delimiter. If the character begins a symbol, string, or number,
698 @kbd{C-M-f} moves over that.
699
700 The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a
701 balanced expression. The detailed rules are like those above for
702 @kbd{C-M-f}, but with directions reversed. If there are prefix
703 characters (single-quote, backquote and comma, in Lisp) preceding the
704 expression, @kbd{C-M-b} moves back over them as well. The balanced
705 expression commands move across comments as if they were whitespace,
706 in most modes.
707
708 @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the
709 specified number of times; with a negative argument, it moves in the
710 opposite direction.
711
712 @cindex killing expressions
713 @kindex C-M-k
714 @findex kill-sexp
715 @kindex C-M-DEL
716 @findex backward-kill-sexp
717 Killing a whole balanced expression can be done with @kbd{C-M-k}
718 (@code{kill-sexp}) or @kbd{C-M-@key{DEL}} (@code{backward-kill-sexp}).
719 @kbd{C-M-k} kills the characters that @kbd{C-M-f} would move over, and
720 @kbd{C-M-@key{DEL}} kills the characters that @kbd{C-M-b} would move
721 over. On some machines, @kbd{C-M-@key{DEL}} typed on the console is a
722 command to reboot; when that is so, you cannot use it as an Emacs
723 command. This conflict is rare, though: usually the @key{DEL} key for
724 Emacs is really @key{BACKSPACE}, and the reboot command is
725 @kbd{C-M-@key{DELETE}}, so there is no conflict.
726
727 @cindex transposition of expressions
728 @kindex C-M-t
729 @findex transpose-sexps
730 A somewhat random-sounding command which is nevertheless handy is
731 @kbd{C-M-t} (@code{transpose-sexps}), which drags the previous
732 balanced expression across the next one. An argument serves as a
733 repeat count, and a negative argument drags backwards (thus canceling
734 out the effect of @kbd{C-M-t} with a positive argument). An argument
735 of zero, rather than doing nothing, transposes the balanced
736 expressions ending after point and the mark.
737
738 @kindex C-M-@@
739 @findex mark-sexp
740 To set the region around the next balanced expression in the buffer,
741 use @kbd{C-M-@@} (@code{mark-sexp}), which sets mark at the same place
742 that @kbd{C-M-f} would move to. @kbd{C-M-@@} takes arguments like
743 @kbd{C-M-f}. In particular, a negative argument is useful for putting
744 the mark at the beginning of the previous balanced expression.
745
746 In languages that use infix operators, such as C, it is not possible
747 to recognize all balanced expressions as such because there can be
748 multiple possibilities at a given position. For example, C mode does
749 not treat @samp{foo + bar} as a single expression, even though it
750 @emph{is} one C expression; instead, it recognizes @samp{foo} as one
751 expression and @samp{bar} as another, with the @samp{+} as punctuation
752 between them. Both @samp{foo + bar} and @samp{foo} are legitimate
753 choices for ``the expression following point'' when point is at the
754 @samp{f}. Note that @samp{(foo + bar)} does act as a single
755 expression in C mode.
756
757 @node Moving by Parens
758 @subsection Moving in the Parenthesis Structure
759
760 @cindex parenthetical groupings
761 @cindex parentheses, moving across
762 @cindex matching parenthesis and braces, moving to
763 @cindex braces, moving across
764 @cindex list commands
765 The Emacs commands for handling parenthetical groupings see nothing
766 except parentheses (or whatever characters must balance in the
767 language you are working with), and the escape characters that might
768 be used to quote those. They are mainly intended for editing
769 programs, but can be useful for editing any text that has parentheses.
770 They are sometimes called ``list'' commands because in Lisp these
771 groupings are lists.
772
773 @table @kbd
774 @item C-M-n
775 Move forward over a parenthetical group (@code{forward-list}).
776 @item C-M-p
777 Move backward over a parenthetical group(@code{backward-list}).
778 @item C-M-u
779 Move up in parenthesis structure (@code{backward-up-list}).
780 @item C-M-d
781 Move down in parenthesis structure (@code{down-list}).
782 @end table
783
784 @kindex C-M-n
785 @kindex C-M-p
786 @findex forward-list
787 @findex backward-list
788 The ``list'' commands @kbd{C-M-n} (@code{forward-list}) and
789 @kbd{C-M-p} (@code{backward-list}) move over one (or @var{n})
790 parenthetical groupings, skipping blithely over any amount of text
791 that doesn't include meaningful parentheses (symbols, strings, etc.).
792
793 @kindex C-M-u
794 @kindex C-M-d
795 @findex backward-up-list
796 @findex down-list
797 @kbd{C-M-n} and @kbd{C-M-p} try to stay at the same level in the
798 parenthesis structure. To move @emph{up} one (or @var{n}) levels, use
799 @kbd{C-M-u} (@code{backward-up-list}). @kbd{C-M-u} moves backward up
800 past one unmatched opening delimiter. A positive argument serves as a
801 repeat count; a negative argument reverses the direction of motion, so
802 that the command moves forward and up one or more levels.
803
804 To move @emph{down} in the parenthesis structure, use @kbd{C-M-d}
805 (@code{down-list}). In Lisp mode, where @samp{(} is the only opening
806 delimiter, this is nearly the same as searching for a @samp{(}. An
807 argument specifies the number of levels to go down.
808
809 @node Matching
810 @subsection Automatic Display Of Matching Parentheses
811 @cindex matching parentheses
812 @cindex parentheses, displaying matches
813
814 The Emacs parenthesis-matching feature is designed to show
815 automatically how parentheses (and other matching delimiters) match in
816 the text. Whenever you type a self-inserting character that is a
817 closing delimiter, the cursor moves momentarily to the location of the
818 matching opening delimiter, provided that is on the screen. If it is
819 not on the screen, Emacs displays some text near it in the echo area.
820 Either way, you can tell what grouping you are closing off.
821
822 If the opening delimiter and closing delimiter are mismatched---such
823 as in @samp{[x)}---a warning message is displayed in the echo area.
824
825 @vindex blink-matching-paren
826 @vindex blink-matching-paren-distance
827 @vindex blink-matching-delay
828 Three variables control parenthesis match display.
829 @code{blink-matching-paren} turns the feature on or off: @code{nil}
830 disables it, but the default is @code{t} to enable match display.
831
832 @code{blink-matching-delay} says how many seconds to leave the
833 cursor on the matching opening delimiter, before bringing it back to
834 the real location of point; the default is 1, but on some systems it
835 is useful to specify a fraction of a second.
836
837 @code{blink-matching-paren-distance} specifies how many characters
838 back to search to find the matching opening delimiter. If the match
839 is not found in that far, scanning stops, and nothing is displayed.
840 This is to prevent the scan for the matching delimiter from wasting
841 lots of time when there is no match. The default is 25600.
842
843 @cindex Show Paren mode
844 @cindex highlighting matching parentheses
845 @findex show-paren-mode
846 Show Paren mode provides a more powerful kind of automatic matching.
847 Whenever point is after a closing delimiter, that delimiter and its
848 matching opening delimiter are both highlighted; otherwise, if point
849 is before an opening delimiter, the matching closing delimiter is
850 highlighted. (There is no need to highlight the opening delimiter in
851 that case, because the cursor appears on top of that character.) Use
852 the command @kbd{M-x show-paren-mode} to enable or disable this mode.
853
854 By default, @code{show-paren-mode} uses colors to highlight the
855 parentheses. However, if your display doesn't support colors, you can
856 customize the faces @code{show-paren-match-face} and
857 @code{show-paren-mismatch-face} to use other attributes, such as bold or
858 underline. @xref{Face Customization}.
859
860 @node Comments
861 @section Manipulating Comments
862 @cindex comments
863
864 Because comments are such an important part of programming, Emacs
865 provides special commands for editing and inserting comments.
866
867 @menu
868 * Comment Commands:: Inserting, killing, and indenting comments.
869 * Multi-Line Comments:: Commands for adding and editing multi-line comments.
870 * Options for Comments::Customizing the comment features.
871 @end menu
872
873 @node Comment Commands
874 @subsection Comment Commands
875 @cindex indentation for comments
876
877 The comment commands in this table insert, kill and align comments.
878 They are described in this section and following sections.
879
880 @table @kbd
881 @item M-;
882 Insert or realign comment on current line; alternatively, comment or
883 uncomment the region (@code{comment-dwim}).
884 @item C-u M-;
885 Kill comment on current line (@code{comment-kill}).
886 @item C-x ;
887 Set comment column (@code{comment-set-column}).
888 @item C-M-j
889 Like @key{RET} followed by inserting and aligning a comment
890 (@code{comment-indent-new-line}).
891 @item M-x comment-region
892 Add or remove comment delimiters on all the lines in the region.
893 @end table
894
895 @kindex M-;
896 @findex comment-dwim
897 The command to create or align a comment is @kbd{M-;}
898 (@code{comment-dwim}). The word ``dwim'' is an acronym for ``Do What
899 I Mean''; it indicates that this command can be used for many
900 different jobs relating to comments, depending on the situation where
901 you use it.
902
903 If there is no comment already on the line, @kbd{M-;} inserts a new
904 comment, aligned at a specific column called the @dfn{comment column}.
905 The new comment begins with the string Emacs thinks comments should
906 start with (the value of @code{comment-start}; see below). Point is
907 after that string, so you can insert the text of the comment right
908 away. If the major mode has specified a string to terminate comments,
909 @kbd{M-;} inserts that too, to keep the syntax valid.
910
911 If the text of the line extends past the comment column, then the
912 comment start string is indented to a suitable boundary (usually, at
913 least one space is inserted).
914
915 You can also use @kbd{M-;} to align an existing comment. If a line
916 already contains the comment-start string, @kbd{M-;} reindents it to
917 the conventional alignment and moves point after it. (Exception:
918 comments starting in column 0 are not moved.) Even when an existing
919 comment is properly aligned, @kbd{M-;} is still useful for moving
920 directly to the start of the text inside the comment.
921
922 @findex comment-kill
923 @kindex C-u M-;
924 @kbd{C-u M-;} kills any comment on the current line, along with the
925 whitespace before it. To reinsert the comment on another line, move
926 to the end of that line, do @kbd{C-y}, and then do @kbd{M-;} to
927 realign it.
928
929 Note that @kbd{C-u M-;} is not a distinct key; it is @kbd{M-;}
930 (@code{comment-dwim}) with a prefix argument. That command is
931 programmed so that when it receives a prefix argument it calls
932 @code{comment-kill}. However, @code{comment-kill} is a valid command
933 in its own right, and you can bind it directly to a key if you wish.
934
935 @kbd{M-;} does two other jobs when used with an active region in
936 Transient Mark mode (@pxref{Transient Mark}). Then it either adds or
937 removes comment delimiters on each line of the region. (If every line
938 is a comment, it removes comment delimiters from each; otherwise, it
939 adds comment delimiters to each.) If you are not using Transient Mark
940 mode, then you should use the commands @code{comment-region} and
941 @code{uncomment-region} to do these jobs (@pxref{Multi-Line Comments}).
942 A prefix argument used in these circumstances specifies how many
943 comment delimiters to add or how many to delete.
944
945 Some major modes have special rules for indenting certain kinds of
946 comments in certain contexts. For example, in Lisp code, comments which
947 start with two semicolons are indented as if they were lines of code,
948 instead of at the comment column. Comments which start with three
949 semicolons are supposed to start at the left margin. Emacs understands
950 these conventions by indenting a double-semicolon comment using @key{TAB},
951 and by not changing the indentation of a triple-semicolon comment at all.
952
953 @example
954 ;; This function is just an example
955 ;;; Here either two or three semicolons are appropriate.
956 (defun foo (x)
957 ;;; And now, the first part of the function:
958 ;; The following line adds one.
959 (1+ x)) ; This line adds one.
960 @end example
961
962 In C code, a comment preceded on its line by nothing but whitespace
963 is indented like a line of code.
964
965 @node Multi-Line Comments
966 @subsection Multiple Lines of Comments
967
968 @kindex C-M-j
969 @cindex blank lines in programs
970 @findex comment-indent-new-line
971 If you are typing a comment and wish to continue it on another line,
972 you can use the command @kbd{C-M-j} (@code{comment-indent-new-line}).
973 This terminates the comment you are typing, creates a new blank line
974 afterward, and begins a new comment indented under the old one. When
975 Auto Fill mode is on, going past the fill column while typing a comment
976 causes the comment to be continued in just this fashion. If point is
977 not at the end of the line when @kbd{C-M-j} is typed, the text on
978 the rest of the line becomes part of the new comment line.
979
980 @findex comment-region
981 To turn existing lines into comment lines, use the @kbd{M-x
982 comment-region} command. It adds comment delimiters to the lines that start
983 in the region, thus commenting them out. With a negative argument, it
984 does the opposite---it deletes comment delimiters from the lines in the
985 region.
986
987 With a positive argument, @code{comment-region} duplicates the last
988 character of the comment start sequence it adds; the argument specifies
989 how many copies of the character to insert. Thus, in Lisp mode,
990 @kbd{C-u 2 M-x comment-region} adds @samp{;;} to each line. Duplicating
991 the comment delimiter is a way of calling attention to the comment. It
992 can also affect how the comment is indented. In Lisp, for proper
993 indentation, you should use an argument of two or three, if between defuns;
994 if within a defun, it must be three.
995
996 @node Options for Comments
997 @subsection Options Controlling Comments
998
999 @vindex comment-column
1000 @kindex C-x ;
1001 @findex comment-set-column
1002 The comment column is stored in the variable @code{comment-column}. You
1003 can set it to a number explicitly. Alternatively, the command @kbd{C-x ;}
1004 (@code{comment-set-column}) sets the comment column to the column point is
1005 at. @kbd{C-u C-x ;} sets the comment column to match the last comment
1006 before point in the buffer, and then does a @kbd{M-;} to align the
1007 current line's comment under the previous one.
1008
1009 The variable @code{comment-column} is per-buffer: setting the variable
1010 in the normal fashion affects only the current buffer, but there is a
1011 default value which you can change with @code{setq-default}.
1012 @xref{Locals}. Many major modes initialize this variable for the
1013 current buffer.
1014
1015 @vindex comment-start-skip
1016 The comment commands recognize comments based on the regular
1017 expression that is the value of the variable @code{comment-start-skip}.
1018 Make sure this regexp does not match the null string. It may match more
1019 than the comment starting delimiter in the strictest sense of the word;
1020 for example, in C mode the value of the variable is
1021 @c This stops M-q from breaking the line inside that @code.
1022 @code{@w{"/\\*+ *\\|//+ *""}}, which matches extra stars and spaces
1023 after the @samp{/*} itself, and accepts C++ style comments also.
1024 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in
1025 the string, which is needed to deny the first star its special meaning
1026 in regexp syntax. @xref{Regexps}.)
1027
1028 @vindex comment-start
1029 @vindex comment-end
1030 When a comment command makes a new comment, it inserts the value of
1031 @code{comment-start} to begin it. The value of @code{comment-end} is
1032 inserted after point, so that it will follow the text that you will insert
1033 into the comment. In C mode, @code{comment-start} has the value
1034 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}.
1035
1036 @vindex comment-padding
1037 The variable @code{comment-padding} specifies how many spaces
1038 @code{comment-region} should insert on each line between the
1039 comment delimiter and the line's original text. The default is 1,
1040 to insert one space.
1041
1042 @vindex comment-multi-line
1043 The variable @code{comment-multi-line} controls how @kbd{C-M-j}
1044 (@code{indent-new-comment-line}) behaves when used inside a comment. If
1045 @code{comment-multi-line} is @code{nil}, as it normally is, then the
1046 comment on the starting line is terminated and a new comment is started
1047 on the new following line. If @code{comment-multi-line} is not
1048 @code{nil}, then the new following line is set up as part of the same
1049 comment that was found on the starting line. This is done by not
1050 inserting a terminator on the old line, and not inserting a starter on
1051 the new line. In languages where multi-line comments work, the choice
1052 of value for this variable is a matter of taste.
1053
1054 @vindex comment-indent-function
1055 The variable @code{comment-indent-function} should contain a function
1056 that will be called to compute the indentation for a newly inserted
1057 comment or for aligning an existing comment. It is set differently by
1058 various major modes. The function is called with no arguments, but with
1059 point at the beginning of the comment, or at the end of a line if a new
1060 comment is to be inserted. It should return the column in which the
1061 comment ought to start. For example, in Lisp mode, the indent hook
1062 function bases its decision on how many semicolons begin an existing
1063 comment, and on the code in the preceding lines.
1064
1065 @node Documentation
1066 @section Documentation Lookup
1067
1068 Emacs provides several features you can use to look up the
1069 documentation of functions, variables and commands that you plan to
1070 use in your program.
1071
1072 @menu
1073 * Info Lookup:: Looking up library functions and commands
1074 in Info files.
1075 * Man Page:: Looking up man pages of library functions and commands.
1076 * Lisp Doc:: Looking up Emacs Lisp functions, etc.
1077 @end menu
1078
1079 @node Info Lookup
1080 @subsection Info Documentation Lookup
1081
1082 @findex info-lookup-symbol
1083 @findex info-lookup-file
1084 @kindex C-h C-i
1085 For C, Lisp, and other languages that have documentation in Info,
1086 you can use @kbd{C-h C-i} (@code{info-lookup-symbol}) to view the Info
1087 documentation for a symbol. You specify the symbol with the
1088 minibuffer; the default is the symbol appearing in the buffer at
1089 point.
1090
1091 The major mode determines where to look for documentation for the
1092 symbol---which Info files to look in, and which indices to search.
1093 You can also use @kbd{M-x info-lookup-file} to look for documentation
1094 for a file name.
1095
1096 This feature currently supports the modes Awk, Autoconf, Bison, C,
1097 Emacs Lisp, LaTeX, M4, Makefile, Octave, Perl, Scheme, and Texinfo,
1098 provided you have installed the relevant Info files, which are
1099 typically available with the appropriate GNU package.
1100
1101 @node Man Page
1102 @subsection Man Page Lookup
1103
1104 Eventually the GNU project hopes to replace most man pages in the
1105 GNU operating system with better-organized manuals that you can browse
1106 with Info (@pxref{Misc Help}). Since this process is not finished, it
1107 is still useful to read manual pages.
1108
1109 @findex manual-entry
1110 @cindex manual pages
1111 You can read the ``man page'' for an operating system command,
1112 library function, or system call, with the @kbd{M-x manual-entry}
1113 command. It runs the @code{man} program to format the man page, and
1114 runs it asynchronously if your system permits, so that you can keep on
1115 editing while the page is being formatted. (MS-DOS and MS-Windows 3
1116 do not permit asynchronous subprocesses, so on these systems you
1117 cannot edit while Emacs waits for @code{man} to finish.) The result
1118 goes in a buffer named @samp{*Man @var{topic}*}. These buffers use a
1119 special major mode, Man mode, that facilitates scrolling and jumping
1120 to other manual pages. For details, type @kbd{C-h m} while in a man
1121 page buffer.
1122
1123 @cindex sections of manual pages
1124 Each man page belongs to one of around ten @dfn{sections}; sometimes
1125 there are multiple man pages with the same name in different sections.
1126 To read a man page from a specific section, type
1127 @samp{@var{topic}(@var{section})} or @samp{@var{section} @var{topic}}
1128 when @kbd{M-x manual-entry} prompts for the topic. For example, to
1129 read the man page for the C library function @code{chmod} (as opposed
1130 to a command by the same name), type @kbd{M-x manual-entry @key{RET}
1131 chmod(2v) @key{RET}} (assuming @code{chmod} is in section @samp{2v}).
1132
1133 If you do not specify a section, the results depend on how the
1134 @code{man} command works on your system. Some of them display only
1135 the first man page they find. Others display all man pages that have
1136 the specified name, so you can move between them with the @kbd{M-n}
1137 and @kbd{M-p} keys. The mode line shows how many manual pages are
1138 present in the Man buffer.
1139
1140 @vindex Man-fontify-manpage-flag
1141 By default, Emacs uses faces in man pages if Emacs can display
1142 different fonts or colors. For a long man page, setting the faces
1143 properly can take substantial time. You can turn off use of faces in
1144 man pages by setting the variable @code{Man-fontify-manpage-flag} to
1145 @code{nil}.
1146
1147 @findex Man-fontify-manpage
1148 If you insert the text of a man page into an Emacs buffer in some
1149 other fashion, you can use the command @kbd{M-x Man-fontify-manpage} to
1150 perform the same conversions that @kbd{M-x manual-entry} does.
1151
1152 @findex woman
1153 @cindex manual pages, on MS-DOS/MS-Windows
1154 An alternative way of reading manual pages is the @kbd{M-x woman}
1155 command@footnote{The name of the command, @code{woman}, is an acronym
1156 for ``w/o (without) man,'' since it doesn't use the @code{man}
1157 program.}. Unlike @kbd{M-x man}, it does not run any external
1158 programs to format and display the man pages; instead it does the job
1159 in Emacs Lisp, so it works on systems such as MS-Windows, where the
1160 @code{man} program (and the other programs it uses) are not generally
1161 available.
1162
1163 @kbd{M-x woman} prompts for a name of a manual page, and provides
1164 completion based on the list of manual pages that are installed on
1165 your machine; the list of available manual pages is computed
1166 automatically the first time you invoke @code{woman}. The word at
1167 point in the current buffer is used to suggest the default for the
1168 name the manual page.
1169
1170 With a numeric argument, @kbd{M-x woman} recomputes the list of the
1171 manual pages used for completion. This is useful if you add or delete
1172 manual pages.
1173
1174 If you type a name of a manual page and @kbd{M-x woman} finds that
1175 several manual pages by the same name exist in different sections, it
1176 pops up a window with possible candidates asking you to choose one of
1177 them.
1178
1179 @vindex woman-manpath
1180 By default, @kbd{M-x woman} looks for manual pages in the
1181 directories specified in the @code{MANPATH} environment variable. (If
1182 @code{MANPATH} is not set, @code{woman} uses a suitable default value,
1183 which can be customized.) More precisely, @code{woman} looks for
1184 subdirectories that match the shell wildcard @file{man*} in each one
1185 of these directories, and tries to find the manual pages in those
1186 subdirectories. When first invoked, @kbd{M-x woman} converts the
1187 value of @code{MANPATH} to a list of directory names and stores that
1188 list in the @code{woman-manpath} variable. Changing the value of this
1189 variable is another way to control the list of directories used.
1190
1191 @vindex woman-path
1192 You can also augment the list of directories searched by
1193 @code{woman} by setting the value of the @code{woman-path} variable.
1194 This variable should hold a list of specific directories which
1195 @code{woman} should search, in addition to those in
1196 @code{woman-manpath}. Unlike @code{woman-manpath}, the directories in
1197 @code{woman-path} are searched for the manual pages, not for
1198 @file{man*} subdirectories.
1199
1200 @findex woman-find-file
1201 Occasionally, you might need to display manual pages that are not in
1202 any of the directories listed by @code{woman-manpath} and
1203 @code{woman-path}. The @kbd{M-x woman-find-file} command prompts for a
1204 name of a manual page file, with completion, and then formats and
1205 displays that file like @kbd{M-x woman} does.
1206
1207 @vindex woman-dired-keys
1208 The first time you invoke @kbd{M-x woman}, it defines the Dired
1209 @kbd{W} key to run the @code{woman-find-file} command on the current
1210 line's file. You can disable this by setting the variable
1211 @code{woman-dired-keys} to @code{nil}. @xref{Dired}. In addition,
1212 the Tar-mode @kbd{w} key is define to invoke @code{woman-find-file} on
1213 the current line's archive member.
1214
1215 For more information about setting up and using @kbd{M-x woman}, see
1216 @ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The WoMan
1217 Manual}.
1218
1219 @node Lisp Doc
1220 @subsection Emacs Lisp Documentation Lookup
1221
1222 As you edit Lisp code to be run in Emacs, you can use the commands
1223 @kbd{C-h f} (@code{describe-function}) and @kbd{C-h v}
1224 (@code{describe-variable}) to view documentation of functions and
1225 variables that you want to use. These commands use the minibuffer to
1226 read the name of a function or variable to document, and display the
1227 documentation in a window. Their default arguments are based on the
1228 code in the neighborhood of point. For @kbd{C-h f}, the default is
1229 the function called in the innermost list containing point. @kbd{C-h
1230 v} uses the symbol name around or adjacent to point as its default.
1231
1232 @cindex Eldoc mode
1233 @findex eldoc-mode
1234 A more automatic but less powerful method is Eldoc mode. This minor
1235 mode constantly displays in the echo area the argument list for the
1236 function being called at point. (In other words, it finds the
1237 function call that point is contained in, and displays the argument
1238 list of that function.) Eldoc mode applies in Emacs Lisp and Lisp
1239 Interaction modes only. Use the command @kbd{M-x eldoc-mode} to
1240 enable or disable this feature.
1241
1242 @node Hideshow
1243 @section Hideshow minor mode
1244
1245 @findex hs-minor-mode
1246 Hideshow minor mode provides selective display of portions of a
1247 program, known as @dfn{blocks}. You can use @kbd{M-x hs-minor-mode}
1248 to enable or disable this mode, or add @code{hs-minor-mode} to the
1249 mode hook for certain major modes in order to enable it automatically
1250 for those modes.
1251
1252 Just what constitutes a block depends on the major mode. In C mode
1253 or C++ mode, they are delimited by braces, while in Lisp mode and
1254 similar modes they are delimited by parentheses. Multi-line comments
1255 also count as blocks.
1256
1257 @findex hs-hide-all
1258 @findex hs-hide-block
1259 @findex hs-show-all
1260 @findex hs-show-block
1261 @findex hs-show-region
1262 @findex hs-hide-level
1263 @findex hs-minor-mode
1264 @kindex C-c @@ C-h
1265 @kindex C-c @@ C-s
1266 @kindex C-c @@ C-M-h
1267 @kindex C-c @@ C-M-s
1268 @kindex C-c @@ C-r
1269 @kindex C-c @@ C-l
1270 @kindex S-Mouse-2
1271 @table @kbd
1272 @item C-c @@ C-h
1273 Hide the current block (@code{hs-hide-block}).
1274 @item C-c @@ C-s
1275 Show the current block (@code{hs-show-block}).
1276 @item C-c @@ C-c
1277 Either hide or show the current block (@code{hs-toggle-hiding})
1278 @item S-Mouse-2
1279 Either hide or show the block you click on (@code{hs-mouse-toggle-hiding})
1280 @item C-c @@ C-M-h
1281 Hide all top-level blocks (@code{hs-hide-all}).
1282 @item C-c @@ C-M-s
1283 Show everything in the buffer (@code{hs-show-all}).
1284 @item C-c @@ C-l
1285 Hide all blocks @var{n} levels below this block
1286 (@code{hs-hide-level}).
1287 @end table
1288
1289 @vindex hs-hide-comments-when-hiding-all
1290 @vindex hs-isearch-open
1291 @vindex hs-special-modes-alist
1292 These user options exist for customizing Hideshow mode.
1293
1294 @table @code
1295 @item hs-hide-comments-when-hiding-all
1296 Non-@code{nil} says that @kbd{hs-hide-all} should hide comments too.
1297
1298 @item hs-isearch-open
1299 Specifies what kind of hidden blocks to open in Isearch mode.
1300 The value should be one of these four symbols.
1301
1302 @table @code
1303 @item block
1304 Open only blocks.
1305 @item comment
1306 Open only comments.
1307 @item t
1308 Open both blocks and comments.
1309 @item nil
1310 Open neither blocks nor comments.
1311 @end table
1312
1313 @item hs-special-modes-alist
1314 A list of elements, each Specifying how to initialize Hideshow
1315 variables for one major mode. See the variable's documentation string
1316 for more information.
1317 @end table
1318
1319 @node Symbol Completion
1320 @section Completion for Symbol Names
1321 @cindex completion (symbol names)
1322
1323 Usually completion happens in the minibuffer. But one kind of completion
1324 is available in all buffers: completion for symbol names.
1325
1326 @kindex M-TAB
1327 The character @kbd{M-@key{TAB}} runs a command to complete the partial
1328 symbol before point against the set of meaningful symbol names. Any
1329 additional characters determined by the partial name are inserted at
1330 point.
1331
1332 If the partial name in the buffer has more than one possible completion
1333 and they have no additional characters in common, a list of all possible
1334 completions is displayed in another window.
1335
1336 @cindex tags-based completion
1337 @cindex Info index completion
1338 @findex complete-symbol
1339 In most programming language major modes, @kbd{M-@key{TAB}} runs the
1340 command @code{complete-symbol}, which provides two kinds of completion.
1341 Normally it does completion based on a tags table (@pxref{Tags}); with a
1342 numeric argument (regardless of the value), it does completion based on
1343 the names listed in the Info file indexes for your language. Thus, to
1344 complete the name of a symbol defined in your own program, use
1345 @kbd{M-@key{TAB}} with no argument; to complete the name of a standard
1346 library function, use @kbd{C-u M-@key{TAB}}. Of course, Info-based
1347 completion works only if there is an Info file for the standard library
1348 functions of your language, and only if it is installed at your site.
1349
1350 @cindex Lisp symbol completion
1351 @cindex completion (Lisp symbols)
1352 @findex lisp-complete-symbol
1353 In Emacs-Lisp mode, the name space for completion normally consists of
1354 nontrivial symbols present in Emacs---those that have function
1355 definitions, values or properties. However, if there is an
1356 open-parenthesis immediately before the beginning of the partial symbol,
1357 only symbols with function definitions are considered as completions.
1358 The command which implements this is @code{lisp-complete-symbol}.
1359
1360 In Text mode and related modes, @kbd{M-@key{TAB}} completes words
1361 based on the spell-checker's dictionary. @xref{Spelling}.
1362
1363 @node Glasses
1364 @section Glasses minor mode
1365 @cindex Glasses mode
1366 @cindex identifiers, making long ones readable
1367 @cindex StudlyCaps, making them readable
1368 @findex glasses-mode
1369
1370 Glasses minor mode makes @samp{unreadableIdentifiersLikeThis}
1371 readable by altering the display. It knows two different ways to do
1372 this: by displaying underscores between a lower-case letter and the
1373 following capital letter, or by emboldening the capital letters. It
1374 does not alter the buffer text, only the way they display, so you can
1375 use it even on read-only buffers. You can use the command @kbd{M-x
1376 glasses-mode} to enable or disable the mode; you can also add
1377 @code{glasses-mode} to the mode hook of appropriate programming
1378 language major modes.
1379
1380 @node Misc for Programs
1381 @section Other Features Useful for Editing Programs
1382
1383 A number of Emacs commands that aren't designed specifically for
1384 editing programs are useful for it nonetheless.
1385
1386 The Emacs commands that operate on words, sentences and paragraphs
1387 are useful for editing code. Most symbols names contain words
1388 (@pxref{Words}); sentences can be found in strings and comments
1389 (@pxref{Sentences}). Paragraphs in the strict sense may be found in
1390 program code (in long comments), but the paragraph commands are useful
1391 in other places too, because programming language major modes define
1392 paragraphs to begin and end at blank lines (@pxref{Paragraphs}).
1393 Judicious use of blank lines to make the program clearer will also
1394 provide useful chunks of text for the paragraph commands to work on.
1395 Auto Fill mode, if enabled in a programming language major mode,
1396 indents the new lines which it creates.
1397
1398 The selective display feature is useful for looking at the overall
1399 structure of a function (@pxref{Selective Display}). This feature
1400 hides the lines that are indented more than a specified amount.
1401 Programming modes often support Outline minor mode (@pxref{Outline
1402 Mode}). The Foldout package provides folding-editor features
1403 (@pxref{Foldout}).
1404
1405 The ``automatic typing'' features may be useful for writing programs.
1406 @xref{Top,,Autotyping, autotype, Autotyping}.
1407
1408 @node C Modes
1409 @section C and Related Modes
1410 @cindex C mode
1411 @cindex Java mode
1412 @cindex Pike mode
1413 @cindex IDL mode
1414 @cindex CORBA IDL mode
1415 @cindex Objective C mode
1416 @cindex C++ mode
1417 @cindex mode, Java
1418 @cindex mode, C
1419 @cindex mode, Objective C
1420 @cindex mode, CORBA IDL
1421 @cindex mode, Pike
1422
1423 This section gives a brief description of the special features
1424 available in C, C++, Objective-C, Java, CORBA IDL, and Pike modes.
1425 (These are called ``C mode and related modes.'') @xref{Top, CC Mode,
1426 ccmode, , CC Mode}, for a more extensive description of these modes
1427 and their special features.
1428
1429 @menu
1430 * Motion in C:: Commands to move by C statements, etc.
1431 * Electric C:: Colon and other chars can automatically reindent.
1432 * Hungry Delete:: A more powerful DEL command.
1433 * Other C Commands:: Filling comments, viewing expansion of macros,
1434 and other neat features.
1435 * Comments in C:: Options for customizing comment style.
1436 @end menu
1437
1438 @node Motion in C
1439 @subsection C Mode Motion Commands
1440
1441 This section describes commands for moving point, in C mode and
1442 related modes.
1443
1444 @table @code
1445 @item C-c C-u
1446 @kindex C-c C-u @r{(C mode)}
1447 @findex c-up-conditional
1448 Move point back to the containing preprocessor conditional, leaving the
1449 mark behind. A prefix argument acts as a repeat count. With a negative
1450 argument, move point forward to the end of the containing
1451 preprocessor conditional. When going backwards, @code{#elif} is treated
1452 like @code{#else} followed by @code{#if}. When going forwards,
1453 @code{#elif} is ignored.@refill
1454
1455 @item C-c C-p
1456 @kindex C-c C-p @r{(C mode)}
1457 @findex c-backward-conditional
1458 Move point back over a preprocessor conditional, leaving the mark
1459 behind. A prefix argument acts as a repeat count. With a negative
1460 argument, move forward.
1461
1462 @item C-c C-n
1463 @kindex C-c C-n @r{(C mode)}
1464 @findex c-forward-conditional
1465 Move point forward across a preprocessor conditional, leaving the mark
1466 behind. A prefix argument acts as a repeat count. With a negative
1467 argument, move backward.
1468
1469 @item M-a
1470 @kindex ESC a
1471 @findex c-beginning-of-statement
1472 Move point to the beginning of the innermost C statement
1473 (@code{c-beginning-of-statement}). If point is already at the beginning
1474 of a statement, move to the beginning of the preceding statement. With
1475 prefix argument @var{n}, move back @var{n} @minus{} 1 statements.
1476
1477 If point is within a string or comment, or next to a comment (only
1478 whitespace between them), this command moves by sentences instead of
1479 statements.
1480
1481 When called from a program, this function takes three optional
1482 arguments: the numeric prefix argument, a buffer position limit
1483 (don't move back before that place), and a flag that controls whether
1484 to do sentence motion when inside of a comment.
1485
1486 @item M-e
1487 @kindex ESC e
1488 @findex c-end-of-statement
1489 Move point to the end of the innermost C statement; like @kbd{M-a}
1490 except that it moves in the other direction (@code{c-end-of-statement}).
1491
1492 @item M-x c-backward-into-nomenclature
1493 @findex c-backward-into-nomenclature
1494 Move point backward to beginning of a C++ nomenclature section or word.
1495 With prefix argument @var{n}, move @var{n} times. If @var{n} is
1496 negative, move forward. C++ nomenclature means a symbol name in the
1497 style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital letter
1498 begins a section or word.
1499
1500 In the GNU project, we recommend using underscores to separate words
1501 within an identifier in C or C++, rather than using case distinctions.
1502
1503 @item M-x c-forward-into-nomenclature
1504 @findex c-forward-into-nomenclature
1505 Move point forward to end of a C++ nomenclature section or word.
1506 With prefix argument @var{n}, move @var{n} times.
1507 @end table
1508
1509 @node Electric C
1510 @subsection Electric C Characters
1511
1512 In C mode and related modes, certain printing characters are
1513 ``electric''---in addition to inserting themselves, they also reindent
1514 the current line and may insert newlines. This feature is controlled by
1515 the variable @code{c-auto-newline}. The ``electric'' characters are
1516 @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#}, @kbd{;}, @kbd{,}, @kbd{<},
1517 @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and @kbd{)}.
1518
1519 Electric characters insert newlines only when the @dfn{auto-newline}
1520 feature is enabled (indicated by @samp{/a} in the mode line after the
1521 mode name). This feature is controlled by the variable
1522 @code{c-auto-newline}. You can turn this feature on or off with the
1523 command @kbd{C-c C-a}:
1524
1525 @table @kbd
1526 @item C-c C-a
1527 @kindex C-c C-a @r{(C mode)}
1528 @findex c-toggle-auto-state
1529 Toggle the auto-newline feature (@code{c-toggle-auto-state}). With a
1530 prefix argument, this command turns the auto-newline feature on if the
1531 argument is positive, and off if it is negative.
1532 @end table
1533
1534 The colon character is electric because that is appropriate for a
1535 single colon. But when you want to insert a double colon in C++, the
1536 electric behavior of colon is inconvenient. You can insert a double
1537 colon with no reindentation or newlines by typing @kbd{C-c :}:
1538
1539 @table @kbd
1540 @item C-c :
1541 @kindex C-c : @r{(C mode)}
1542 @findex c-scope-operator
1543 Insert a double colon scope operator at point, without reindenting the
1544 line or adding any newlines (@code{c-scope-operator}).
1545 @end table
1546
1547 The electric @kbd{#} key reindents the line if it appears to be the
1548 beginning of a preprocessor directive. This happens when the value of
1549 @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn
1550 this feature off by setting @code{c-electric-pound-behavior} to
1551 @code{nil}.
1552
1553 The variable @code{c-hanging-braces-alist} controls the insertion of
1554 newlines before and after inserted braces. It is an association list
1555 with elements of the following form: @code{(@var{syntactic-symbol}
1556 . @var{nl-list})}. Most of the syntactic symbols that appear in
1557 @code{c-offsets-alist} are meaningful here as well.
1558
1559 The list @var{nl-list} may contain either of the symbols
1560 @code{before} or @code{after}, or both; or it may be @code{nil}. When a
1561 brace is inserted, the syntactic context it defines is looked up in
1562 @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used
1563 to determine where newlines are inserted: either before the brace,
1564 after, or both. If not found, the default is to insert a newline both
1565 before and after braces.
1566
1567 The variable @code{c-hanging-colons-alist} controls the insertion of
1568 newlines before and after inserted colons. It is an association list
1569 with elements of the following form: @code{(@var{syntactic-symbol}
1570 . @var{nl-list})}. The list @var{nl-list} may contain either of the
1571 symbols @code{before} or @code{after}, or both; or it may be @code{nil}.
1572
1573 When a colon is inserted, the syntactic symbol it defines is looked
1574 up in this list, and if found, the @var{nl-list} is used to determine
1575 where newlines are inserted: either before the brace, after, or both.
1576 If the syntactic symbol is not found in this list, no newlines are
1577 inserted.
1578
1579 Electric characters can also delete newlines automatically when the
1580 auto-newline feature is enabled. This feature makes auto-newline more
1581 acceptable, by deleting the newlines in the most common cases where you
1582 do not want them. Emacs can recognize several cases in which deleting a
1583 newline might be desirable; by setting the variable
1584 @code{c-cleanup-list}, you can specify @emph{which} of these cases that
1585 should happen. The variable's value is a list of symbols, each
1586 describing one case for possible deletion of a newline. Here are the
1587 meaningful symbols, and their meanings:
1588
1589 @table @code
1590 @item brace-catch-brace
1591 Clean up @samp{@} catch (@var{condition}) @{} constructs by placing the
1592 entire construct on a single line. The clean-up occurs when you type
1593 the @samp{@{}, if there is nothing between the braces aside from
1594 @code{catch} and @var{condition}.
1595
1596 @item brace-else-brace
1597 Clean up @samp{@} else @{} constructs by placing the entire construct on
1598 a single line. The clean-up occurs when you type the @samp{@{} after
1599 the @code{else}, but only if there is nothing but white space between
1600 the braces and the @code{else}.
1601
1602 @item brace-elseif-brace
1603 Clean up @samp{@} else if (@dots{}) @{} constructs by placing the entire
1604 construct on a single line. The clean-up occurs when you type the
1605 @samp{@{}, if there is nothing but white space between the @samp{@}} and
1606 @samp{@{} aside from the keywords and the @code{if}-condition.
1607
1608 @item empty-defun-braces
1609 Clean up empty defun braces by placing the braces on the same
1610 line. Clean-up occurs when you type the closing brace.
1611
1612 @item defun-close-semi
1613 Clean up the semicolon after a @code{struct} or similar type
1614 declaration, by placing the semicolon on the same line as the closing
1615 brace. Clean-up occurs when you type the semicolon.
1616
1617 @item list-close-comma
1618 Clean up commas following braces in array and aggregate
1619 initializers. Clean-up occurs when you type the comma.
1620
1621 @item scope-operator
1622 Clean up double colons which may designate a C++ scope operator, by
1623 placing the colons together. Clean-up occurs when you type the second
1624 colon, but only when the two colons are separated by nothing but
1625 whitespace.
1626 @end table
1627
1628 @node Hungry Delete
1629 @subsection Hungry Delete Feature in C
1630
1631 When the @dfn{hungry-delete} feature is enabled (indicated by
1632 @samp{/h} or @samp{/ah} in the mode line after the mode name), a single
1633 @key{DEL} command deletes all preceding whitespace, not just one space.
1634 To turn this feature on or off, use @kbd{C-c C-d}:
1635
1636 @table @kbd
1637 @item C-c C-d
1638 @kindex C-c C-d @r{(C mode)}
1639 @findex c-toggle-hungry-state
1640 Toggle the hungry-delete feature (@code{c-toggle-hungry-state}). With a
1641 prefix argument, this command turns the hungry-delete feature on if the
1642 argument is positive, and off if it is negative.
1643
1644 @item C-c C-t
1645 @kindex C-c C-t @r{(C mode)}
1646 @findex c-toggle-auto-hungry-state
1647 Toggle the auto-newline and hungry-delete features, both at once
1648 (@code{c-toggle-auto-hungry-state}).
1649 @end table
1650
1651 @vindex c-hungry-delete-key
1652 The variable @code{c-hungry-delete-key} controls whether the
1653 hungry-delete feature is enabled.
1654
1655 @node Other C Commands
1656 @subsection Other Commands for C Mode
1657
1658 @table @kbd
1659 @item C-M-h
1660 Put mark at the end of a function definition, and put point at the
1661 beginning (@code{c-mark-function}).
1662
1663 @item M-q
1664 @kindex M-q @r{(C mode)}
1665 @findex c-fill-paragraph
1666 Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}).
1667 If any part of the current line is a comment or within a comment, this
1668 command fills the comment or the paragraph of it that point is in,
1669 preserving the comment indentation and comment delimiters.
1670
1671 @item C-c C-e
1672 @cindex macro expansion in C
1673 @cindex expansion of C macros
1674 @findex c-macro-expand
1675 @kindex C-c C-e @r{(C mode)}
1676 Run the C preprocessor on the text in the region, and show the result,
1677 which includes the expansion of all the macro calls
1678 (@code{c-macro-expand}). The buffer text before the region is also
1679 included in preprocessing, for the sake of macros defined there, but the
1680 output from this part isn't shown.
1681
1682 When you are debugging C code that uses macros, sometimes it is hard to
1683 figure out precisely how the macros expand. With this command, you
1684 don't have to figure it out; you can see the expansions.
1685
1686 @item C-c C-\
1687 @findex c-backslash-region
1688 @kindex C-c C-\ @r{(C mode)}
1689 Insert or align @samp{\} characters at the ends of the lines of the
1690 region (@code{c-backslash-region}). This is useful after writing or
1691 editing a C macro definition.
1692
1693 If a line already ends in @samp{\}, this command adjusts the amount of
1694 whitespace before it. Otherwise, it inserts a new @samp{\}. However,
1695 the last line in the region is treated specially; no @samp{\} is
1696 inserted on that line, and any @samp{\} there is deleted.
1697
1698 @item M-x cpp-highlight-buffer
1699 @cindex preprocessor highlighting
1700 @findex cpp-highlight-buffer
1701 Highlight parts of the text according to its preprocessor conditionals.
1702 This command displays another buffer named @samp{*CPP Edit*}, which
1703 serves as a graphic menu for selecting how to display particular kinds
1704 of conditionals and their contents. After changing various settings,
1705 click on @samp{[A]pply these settings} (or go to that buffer and type
1706 @kbd{a}) to rehighlight the C mode buffer accordingly.
1707
1708 @item C-c C-s
1709 @findex c-show-syntactic-information
1710 @kindex C-c C-s @r{(C mode)}
1711 Display the syntactic information about the current source line
1712 (@code{c-show-syntactic-information}). This is the information that
1713 directs how the line is indented.
1714
1715 @item M-x cwarn-mode
1716 @itemx M-x global-cwarn-mode
1717 @findex cwarn-mode
1718 @findex global-cwarn-mode
1719 @cindex CWarn mode
1720 @cindex suspicious constructions in C, C++
1721 CWarn minor mode highlights certain suspicious C and C++ constructions:
1722
1723 @itemize @bullet{}
1724 @item
1725 Assignments inside expressions.
1726 @item
1727 Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while}
1728 (except after a @samp{do @dots{} while} statement);
1729 @item
1730 C++ functions with reference parameters.
1731 @end itemize
1732
1733 @noindent
1734 You can enable the mode for one buffer with the command @kbd{M-x
1735 cwarn-mode}, or for all suitable buffers with the command @kbd{M-x
1736 global-cwarn-mode} or by customizing the variable
1737 @code{global-cwarn-mode}. You must also enable Font Lock mode to make
1738 it work.
1739
1740 @item M-x hide-ifdef-mode
1741 @findex hide-ifdef-mode
1742 @cindex Hide-ifdef mode
1743 Hide-ifdef minor mode hides selected code within @samp{#if} and
1744 @samp{#ifdef} preprocessor blocks. See the documentation string of
1745 @code{hide-ifdef-mode} for more information.
1746
1747 @item M-x ff-find-related-file
1748 @cindex related files
1749 @findex ff-find-related-file
1750 @vindex ff-related-file-alist
1751 Find a file ``related'' in a special way to the file visited by the
1752 current buffer. Typically this will be the header file corresponding
1753 to a C/C++ source file, or vice versa. The variable
1754 @code{ff-related-file-alist} specifies how to compute related file
1755 names.
1756 @end table
1757
1758 @node Comments in C
1759 @subsection Comments in C Modes
1760
1761 C mode and related modes use a number of variables for controlling
1762 comment format.
1763
1764 @table @code
1765 @item c-comment-only-line-offset
1766 @vindex c-comment-only-line-offset
1767 Extra offset for line which contains only the start of a comment. It
1768 can be either an integer or a cons cell of the form
1769 @code{(@var{non-anchored-offset} . @var{anchored-offset})}, where
1770 @var{non-anchored-offset} is the amount of offset given to
1771 non-column-zero anchored comment-only lines, and @var{anchored-offset}
1772 is the amount of offset to give column-zero anchored comment-only lines.
1773 Just an integer as value is equivalent to @code{(@var{val} . 0)}.
1774
1775 @item c-comment-start-regexp
1776 @vindex c-comment-start-regexp
1777 This buffer-local variable specifies how to recognize the start of a comment.
1778
1779 @item c-hanging-comment-ender-p
1780 @vindex c-hanging-comment-ender-p
1781 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
1782 comment terminator of a block comment on a line by itself. The default
1783 value is @code{t}, which puts the comment-end delimiter @samp{*/} at the
1784 end of the last line of the comment text.
1785
1786 @item c-hanging-comment-starter-p
1787 @vindex c-hanging-comment-starter-p
1788 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
1789 starting delimiter of a block comment on a line by itself. The default
1790 value is @code{t}, which puts the comment-start delimiter @samp{/*} at
1791 the beginning of the first line of the comment text.
1792 @end table
1793
1794 @node Fortran
1795 @section Fortran Mode
1796 @cindex Fortran mode
1797 @cindex mode, Fortran
1798
1799 Fortran mode provides special motion commands for Fortran statements and
1800 subprograms, and indentation commands that understand Fortran conventions
1801 of nesting, line numbers and continuation statements. Fortran mode has
1802 its own Auto Fill mode that breaks long lines into proper Fortran
1803 continuation lines.
1804
1805 Special commands for comments are provided because Fortran comments
1806 are unlike those of other languages. Built-in abbrevs optionally save
1807 typing when you insert Fortran keywords.
1808
1809 Use @kbd{M-x fortran-mode} to switch to this major mode. This command
1810 runs the hook @code{fortran-mode-hook} (@pxref{Hooks}).
1811
1812 @cindex Fortran77 and Fortran90
1813 @findex f90-mode
1814 @findex fortran-mode
1815 Fortan mode is meant for editing Fortran77 ``fixed format'' source
1816 code. For editing the modern Fortran90 ``free format'' source code,
1817 use F90 mode (@code{f90-mode}). Emacs normally uses Fortran mode for
1818 files with extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode
1819 for the extension @samp{.f90}. GNU Fortran supports both kinds of
1820 format.
1821
1822 @menu
1823 * Motion: Fortran Motion. Moving point by statements or subprograms.
1824 * Indent: Fortran Indent. Indentation commands for Fortran.
1825 * Comments: Fortran Comments. Inserting and aligning comments.
1826 * Autofill: Fortran Autofill. Auto fill minor mode for Fortran.
1827 * Columns: Fortran Columns. Measuring columns for valid Fortran.
1828 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
1829 @end menu
1830
1831 @node Fortran Motion
1832 @subsection Motion Commands
1833
1834 In addition to the normal commands for moving by and operating on
1835 ``defuns'' (Fortran subprograms---functions and subroutines), Fortran
1836 mode provides special commands to move by statements.
1837
1838 @table @kbd
1839 @kindex C-c C-n @r{(Fortran mode)}
1840 @findex fortran-next-statement
1841 @item C-c C-n
1842 Move to beginning of current or next statement
1843 (@code{fortran-next-statement}).
1844
1845 @kindex C-c C-p @r{(Fortran mode)}
1846 @findex fortran-previous-statement
1847 @item C-c C-p
1848 Move to beginning of current or previous statement
1849 (@code{fortran-previous-statement}).
1850 @end table
1851
1852 @node Fortran Indent
1853 @subsection Fortran Indentation
1854
1855 Special commands and features are needed for indenting Fortran code in
1856 order to make sure various syntactic entities (line numbers, comment line
1857 indicators and continuation line flags) appear in the columns that are
1858 required for standard Fortran.
1859
1860 @menu
1861 * Commands: ForIndent Commands. Commands for indenting and filling Fortran.
1862 * Contline: ForIndent Cont. How continuation lines indent.
1863 * Numbers: ForIndent Num. How line numbers auto-indent.
1864 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
1865 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
1866 @end menu
1867
1868 @node ForIndent Commands
1869 @subsubsection Fortran Indentation and Filling Commands
1870
1871 @table @kbd
1872 @item C-M-j
1873 Break the current line and set up a continuation line
1874 (@code{fortran-split-line}).
1875 @item M-^
1876 Join this line to the previous line (@code{fortran-join-line}).
1877 @item C-M-q
1878 Indent all the lines of the subprogram point is in
1879 (@code{fortran-indent-subprogram}).
1880 @item M-q
1881 Fill a comment block or statement.
1882 @end table
1883
1884 @kindex C-M-q @r{(Fortran mode)}
1885 @findex fortran-indent-subprogram
1886 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command
1887 to reindent all the lines of the Fortran subprogram (function or
1888 subroutine) containing point.
1889
1890 @kindex C-M-j @r{(Fortran mode)}
1891 @findex fortran-split-line
1892 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits
1893 a line in the appropriate fashion for Fortran. In a non-comment line,
1894 the second half becomes a continuation line and is indented
1895 accordingly. In a comment line, both halves become separate comment
1896 lines.
1897
1898 @kindex M-^ @r{(Fortran mode)}
1899 @kindex C-c C-d @r{(Fortran mode)}
1900 @findex fortran-join-line
1901 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line},
1902 which joins a continuation line back to the previous line, roughly as
1903 the inverse of @code{fortran-split-line}. The point must be on a
1904 continuation line when this command is invoked.
1905
1906 @kindex M-q @r{(Fortran mode)}
1907 @kbd{M-q} in Fortran mode fills the comment block or statement that
1908 point is in. This removes any excess statement continuations.
1909
1910 @node ForIndent Cont
1911 @subsubsection Continuation Lines
1912 @cindex Fortran continuation lines
1913
1914 @vindex fortran-continuation-string
1915 Most modern Fortran compilers allow two ways of writing continuation
1916 lines. If the first non-space character on a line is in column 5, then
1917 that line is a continuation of the previous line. We call this
1918 @dfn{fixed format}. (In GNU Emacs we always count columns from 0.) The
1919 variable @code{fortran-continuation-string} specifies what character to
1920 put on column 5. A line that starts with a tab character followed by
1921 any digit except @samp{0} is also a continuation line. We call this
1922 style of continuation @dfn{tab format}.
1923
1924 @vindex indent-tabs-mode @r{(Fortran mode)}
1925 Fortran mode can make either style of continuation line, but you
1926 must specify which one you prefer. The value of the variable
1927 @code{indent-tabs-mode} controls the choice: @code{nil} for fixed
1928 format, and non-@code{nil} for tab format. You can tell which style
1929 is presently in effect by the presence or absence of the string
1930 @samp{Tab} in the mode line.
1931
1932 If the text on a line starts with the conventional Fortran
1933 continuation marker @samp{$}, or if it begins with any non-whitespace
1934 character in column 5, Fortran mode treats it as a continuation line.
1935 When you indent a continuation line with @key{TAB}, it converts the line
1936 to the current continuation style. When you split a Fortran statement
1937 with @kbd{C-M-j}, the continuation marker on the newline is created
1938 according to the continuation style.
1939
1940 The setting of continuation style affects several other aspects of
1941 editing in Fortran mode. In fixed format mode, the minimum column
1942 number for the body of a statement is 6. Lines inside of Fortran
1943 blocks that are indented to larger column numbers always use only the
1944 space character for whitespace. In tab format mode, the minimum
1945 column number for the statement body is 8, and the whitespace before
1946 column 8 must always consist of one tab character.
1947
1948 @vindex fortran-tab-mode-default
1949 @vindex fortran-analyze-depth
1950 When you enter Fortran mode for an existing file, it tries to deduce the
1951 proper continuation style automatically from the file contents. The first
1952 line that begins with either a tab character or six spaces determines the
1953 choice. The variable @code{fortran-analyze-depth} specifies how many lines
1954 to consider (at the beginning of the file); if none of those lines
1955 indicates a style, then the variable @code{fortran-tab-mode-default}
1956 specifies the style. If it is @code{nil}, that specifies fixed format, and
1957 non-@code{nil} specifies tab format.
1958
1959 @node ForIndent Num
1960 @subsubsection Line Numbers
1961
1962 If a number is the first non-whitespace in the line, Fortran
1963 indentation assumes it is a line number and moves it to columns 0
1964 through 4. (Columns always count from 0 in GNU Emacs.)
1965
1966 @vindex fortran-line-number-indent
1967 Line numbers of four digits or less are normally indented one space.
1968 The variable @code{fortran-line-number-indent} controls this; it
1969 specifies the maximum indentation a line number can have. Line numbers
1970 are indented to right-justify them to end in column 4 unless that would
1971 require more than this maximum indentation. The default value of the
1972 variable is 1.
1973
1974 @vindex fortran-electric-line-number
1975 Simply inserting a line number is enough to indent it according to
1976 these rules. As each digit is inserted, the indentation is recomputed.
1977 To turn off this feature, set the variable
1978 @code{fortran-electric-line-number} to @code{nil}. Then inserting line
1979 numbers is like inserting anything else.
1980
1981 @node ForIndent Conv
1982 @subsubsection Syntactic Conventions
1983
1984 Fortran mode assumes that you follow certain conventions that simplify
1985 the task of understanding a Fortran program well enough to indent it
1986 properly:
1987
1988 @itemize @bullet
1989 @item
1990 Two nested @samp{do} loops never share a @samp{continue} statement.
1991
1992 @item
1993 Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do}
1994 and others are written without embedded whitespace or line breaks.
1995
1996 Fortran compilers generally ignore whitespace outside of string
1997 constants, but Fortran mode does not recognize these keywords if they
1998 are not contiguous. Constructs such as @samp{else if} or @samp{end do}
1999 are acceptable, but the second word should be on the same line as the
2000 first and not on a continuation line.
2001 @end itemize
2002
2003 @noindent
2004 If you fail to follow these conventions, the indentation commands may
2005 indent some lines unaesthetically. However, a correct Fortran program
2006 retains its meaning when reindented even if the conventions are not
2007 followed.
2008
2009 @node ForIndent Vars
2010 @subsubsection Variables for Fortran Indentation
2011
2012 @vindex fortran-do-indent
2013 @vindex fortran-if-indent
2014 @vindex fortran-structure-indent
2015 @vindex fortran-continuation-indent
2016 @vindex fortran-check-all-num@dots{}
2017 @vindex fortran-minimum-statement-indent@dots{}
2018 Several additional variables control how Fortran indentation works:
2019
2020 @table @code
2021 @item fortran-do-indent
2022 Extra indentation within each level of @samp{do} statement (default 3).
2023
2024 @item fortran-if-indent
2025 Extra indentation within each level of @samp{if} statement (default 3).
2026 This value is also used for extra indentation within each level of the
2027 Fortran 90 @samp{where} statement.
2028
2029 @item fortran-structure-indent
2030 Extra indentation within each level of @samp{structure}, @samp{union}, or
2031 @samp{map} statements (default 3).
2032
2033 @item fortran-continuation-indent
2034 Extra indentation for bodies of continuation lines (default 5).
2035
2036 @item fortran-check-all-num-for-matching-do
2037 If this is @code{nil}, indentation assumes that each @samp{do} statement
2038 ends on a @samp{continue} statement. Therefore, when computing
2039 indentation for a statement other than @samp{continue}, it can save time
2040 by not checking for a @samp{do} statement ending there. If this is
2041 non-@code{nil}, indenting any numbered statement must check for a
2042 @samp{do} that ends there. The default is @code{nil}.
2043
2044 @item fortran-blink-matching-if
2045 If this is @code{t}, indenting an @samp{endif} statement moves the
2046 cursor momentarily to the matching @samp{if} statement to show where it
2047 is. The default is @code{nil}.
2048
2049 @item fortran-minimum-statement-indent-fixed
2050 Minimum indentation for fortran statements when using fixed format
2051 continuation line style. Statement bodies are never indented less than
2052 this much. The default is 6.
2053
2054 @item fortran-minimum-statement-indent-tab
2055 Minimum indentation for fortran statements for tab format continuation line
2056 style. Statement bodies are never indented less than this much. The
2057 default is 8.
2058 @end table
2059
2060 @node Fortran Comments
2061 @subsection Fortran Comments
2062
2063 The usual Emacs comment commands assume that a comment can follow a line
2064 of code. In Fortran, the standard comment syntax requires an entire line
2065 to be just a comment. Therefore, Fortran mode replaces the standard Emacs
2066 comment commands and defines some new variables.
2067
2068 Fortran mode can also handle the Fortran90 comment syntax where comments
2069 start with @samp{!} and can follow other text. Because only some Fortran77
2070 compilers accept this syntax, Fortran mode will not insert such comments
2071 unless you have said in advance to do so. To do this, set the variable
2072 @code{comment-start} to @samp{"!"} (@pxref{Variables}).
2073
2074 @table @kbd
2075 @item M-;
2076 Align comment or insert new comment (@code{fortran-comment-indent}).
2077
2078 @item C-x ;
2079 Applies to nonstandard @samp{!} comments only.
2080
2081 @item C-c ;
2082 Turn all lines of the region into comments, or (with argument) turn them back
2083 into real code (@code{fortran-comment-region}).
2084 @end table
2085
2086 @kbd{M-;} in Fortran mode is redefined as the command
2087 @code{fortran-comment-indent}. Like the usual @kbd{M-;} command, this
2088 recognizes any kind of existing comment and aligns its text appropriately;
2089 if there is no existing comment, a comment is inserted and aligned. But
2090 inserting and aligning comments are not the same in Fortran mode as in
2091 other modes.
2092
2093 When a new comment must be inserted, if the current line is blank, a
2094 full-line comment is inserted. On a non-blank line, a nonstandard @samp{!}
2095 comment is inserted if you have said you want to use them. Otherwise a
2096 full-line comment is inserted on a new line before the current line.
2097
2098 Nonstandard @samp{!} comments are aligned like comments in other
2099 languages, but full-line comments are different. In a standard full-line
2100 comment, the comment delimiter itself must always appear in column zero.
2101 What can be aligned is the text within the comment. You can choose from
2102 three styles of alignment by setting the variable
2103 @code{fortran-comment-indent-style} to one of these values:
2104
2105 @vindex fortran-comment-indent-style
2106 @vindex fortran-comment-line-extra-indent
2107 @table @code
2108 @item fixed
2109 Align the text at a fixed column, which is the sum of
2110 @code{fortran-comment-line-extra-indent} and the minimum statement
2111 indentation. This is the default.
2112
2113 The minimum statement indentation is
2114 @code{fortran-minimum-statement-indent-fixed} for fixed format
2115 continuation line style and @code{fortran-minimum-statement-indent-tab}
2116 for tab format style.
2117
2118 @item relative
2119 Align the text as if it were a line of code, but with an additional
2120 @code{fortran-comment-line-extra-indent} columns of indentation.
2121
2122 @item nil
2123 Don't move text in full-line comments automatically at all.
2124 @end table
2125
2126 @vindex fortran-comment-indent-char
2127 In addition, you can specify the character to be used to indent within
2128 full-line comments by setting the variable
2129 @code{fortran-comment-indent-char} to the single-character string you want
2130 to use.
2131
2132 @vindex comment-line-start
2133 @vindex comment-line-start-skip
2134 Fortran mode introduces two variables @code{comment-line-start} and
2135 @code{comment-line-start-skip}, which play for full-line comments the same
2136 roles played by @code{comment-start} and @code{comment-start-skip} for
2137 ordinary text-following comments. Normally these are set properly by
2138 Fortran mode, so you do not need to change them.
2139
2140 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If
2141 you use @samp{!} comments, this command can be used with them. Otherwise
2142 it is useless in Fortran mode.
2143
2144 @kindex C-c ; @r{(Fortran mode)}
2145 @findex fortran-comment-region
2146 @vindex fortran-comment-region
2147 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
2148 lines of the region into comments by inserting the string @samp{C$$$} at
2149 the front of each one. With a numeric argument, it turns the region
2150 back into live code by deleting @samp{C$$$} from the front of each line
2151 in it. The string used for these comments can be controlled by setting
2152 the variable @code{fortran-comment-region}. Note that here we have an
2153 example of a command and a variable with the same name; these two uses
2154 of the name never conflict because in Lisp and in Emacs it is always
2155 clear from the context which one is meant.
2156
2157 @node Fortran Autofill
2158 @subsection Fortran Auto Fill Mode
2159
2160 Fortran Auto Fill mode is a minor mode which automatically splits
2161 Fortran statements as you insert them when they become too wide.
2162 Splitting a statement involves making continuation lines using
2163 @code{fortran-continuation-string} (@pxref{ForIndent Cont}). This
2164 splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and
2165 also in the Fortran indentation commands.
2166
2167 @findex fortran-auto-fill-mode
2168 @kbd{M-x fortran-auto-fill-mode} turns Fortran Auto Fill mode on if it
2169 was off, or off if it was on. This command works the same as @kbd{M-x
2170 auto-fill-mode} does for normal Auto Fill mode (@pxref{Filling}). A
2171 positive numeric argument turns Fortran Auto Fill mode on, and a
2172 negative argument turns it off. You can see when Fortran Auto Fill mode
2173 is in effect by the presence of the word @samp{Fill} in the mode line,
2174 inside the parentheses. Fortran Auto Fill mode is a minor mode, turned
2175 on or off for each buffer individually. @xref{Minor Modes}.
2176
2177 @vindex fortran-break-before-delimiters
2178 Fortran Auto Fill mode breaks lines at spaces or delimiters when the
2179 lines get longer than the desired width (the value of @code{fill-column}).
2180 The delimiters that Fortran Auto Fill mode may break at are @samp{,},
2181 @samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}.
2182 The line break comes after the delimiter if the variable
2183 @code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by
2184 default), the break comes before the delimiter.
2185
2186 By default, Fortran Auto Fill mode is not enabled. If you want this
2187 feature turned on permanently, add a hook function to
2188 @code{fortran-mode-hook} to execute @code{(fortran-auto-fill-mode 1)}.
2189 @xref{Hooks}.
2190
2191 @node Fortran Columns
2192 @subsection Checking Columns in Fortran
2193
2194 @table @kbd
2195 @item C-c C-r
2196 Display a ``column ruler'' momentarily above the current line
2197 (@code{fortran-column-ruler}).
2198 @item C-c C-w
2199 Split the current window horizontally temporarily so that it is 72
2200 columns wide (@code{fortran-window-create-momentarily}). This may
2201 help you avoid making lines longer than the 72-character limit that
2202 some Fortran compilers impose.
2203 @item C-u C-c C-w
2204 Split the current window horizontally so that it is 72 columns wide
2205 (@code{fortran-window-create}). You can then continue editing.
2206 @item M-x fortran-strip-sequence-nos
2207 Delete all text in column 72 and beyond.
2208 @end table
2209
2210 @kindex C-c C-r @r{(Fortran mode)}
2211 @findex fortran-column-ruler
2212 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column
2213 ruler momentarily above the current line. The comment ruler is two lines
2214 of text that show you the locations of columns with special significance in
2215 Fortran programs. Square brackets show the limits of the columns for line
2216 numbers, and curly brackets show the limits of the columns for the
2217 statement body. Column numbers appear above them.
2218
2219 Note that the column numbers count from zero, as always in GNU Emacs.
2220 As a result, the numbers may be one less than those you are familiar
2221 with; but the positions they indicate in the line are standard for
2222 Fortran.
2223
2224 @vindex fortran-column-ruler-fixed
2225 @vindex fortran-column-ruler-tabs
2226 The text used to display the column ruler depends on the value of
2227 the variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is
2228 @code{nil}, then the value of the variable
2229 @code{fortran-column-ruler-fixed} is used as the column ruler.
2230 Otherwise, the variable @code{fortran-column-ruler-tab} is displayed.
2231 By changing these variables, you can change the column ruler display.
2232
2233 @kindex C-c C-w @r{(Fortran mode)}
2234 @findex fortran-window-create-momentarily
2235 @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily
2236 splits the current window horizontally, making a window 72 columns
2237 wide, so you can see which lines that is too long. Type a space to
2238 restore the normal width.
2239
2240 @kindex C-u C-c C-w @r{(Fortran mode)}
2241 @findex fortran-window-create
2242 You can also split the window horizontally and continue editing with
2243 the split in place. To do this, use @kbd{C-u C-c C-w} (@code{M-x
2244 fortran-window-create}). By editing in this window you can
2245 immediately see when you make a line too wide to be correct Fortran.
2246
2247 @findex fortran-strip-sequence-nos
2248 The command @kbd{M-x fortran-strip-sequence-nos} deletes all text in
2249 column 72 and beyond, on all lines in the current buffer. This is the
2250 easiest way to get rid of old sequence numbers.
2251
2252 @node Fortran Abbrev
2253 @subsection Fortran Keyword Abbrevs
2254
2255 Fortran mode provides many built-in abbrevs for common keywords and
2256 declarations. These are the same sort of abbrev that you can define
2257 yourself. To use them, you must turn on Abbrev mode. @xref{Abbrevs}.
2258
2259 The built-in abbrevs are unusual in one way: they all start with a
2260 semicolon. You cannot normally use semicolon in an abbrev, but Fortran
2261 mode makes this possible by changing the syntax of semicolon to ``word
2262 constituent.''
2263
2264 For example, one built-in Fortran abbrev is @samp{;c} for
2265 @samp{continue}. If you insert @samp{;c} and then insert a punctuation
2266 character such as a space or a newline, the @samp{;c} expands automatically
2267 to @samp{continue}, provided Abbrev mode is enabled.@refill
2268
2269 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in
2270 Fortran abbrevs and what they stand for.
2271
2272 @node Asm Mode
2273 @section Asm Mode
2274
2275 @cindex Asm mode
2276 @cindex assembler mode
2277 Asm mode is a major mode for editing files of assembler code. It
2278 defines these commands:
2279
2280 @table @kbd
2281 @item @key{TAB}
2282 @code{tab-to-tab-stop}.
2283 @item C-j
2284 Insert a newline and then indent using @code{tab-to-tab-stop}.
2285 @item :
2286 Insert a colon and then remove the indentation from before the label
2287 preceding colon. Then do @code{tab-to-tab-stop}.
2288 @item ;
2289 Insert or align a comment.
2290 @end table
2291
2292 The variable @code{asm-comment-char} specifies which character
2293 starts comments in assembler syntax.