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