]> code.delx.au - gnu-emacs/blob - doc/emacs/programs.texi
(Moving by Parens): Clarify that parens inside strings and comments are
[gnu-emacs] / doc / emacs / 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, 2007, 2008 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 * Asm Mode:: Asm mode and its special features.
45 @ifnottex
46 * Fortran:: Fortran mode and its special features.
47 @end ifnottex
48 @end menu
49
50 @node Program Modes
51 @section Major Modes for Programming Languages
52 @cindex modes for programming languages
53
54 Emacs has specialized major modes for various programming languages.
55 @xref{Major Modes}. A programming language major mode typically
56 specifies the syntax of expressions, the customary rules for
57 indentation, how to do syntax highlighting for the language, and how
58 to find the beginning or end of a function definition. It often
59 customizes or provides facilities for compiling and debugging programs
60 as well.
61
62 Ideally, Emacs should provide a major mode for each programming
63 language that you might want to edit; if it doesn't have a mode for
64 your favorite language, you can contribute one. But often the mode
65 for one language can serve for other syntactically similar languages.
66 The major mode for language @var{l} is called @code{@var{l}-mode},
67 and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}.
68 @xref{Choosing Modes}.
69
70 @cindex Perl mode
71 @cindex Icon mode
72 @cindex Makefile mode
73 @cindex Tcl mode
74 @cindex CPerl mode
75 @cindex DSSSL mode
76 @cindex Octave mode
77 @cindex Metafont mode
78 @cindex Modula2 mode
79 @cindex Prolog mode
80 @cindex Python mode
81 @cindex Simula mode
82 @cindex VHDL mode
83 @cindex M4 mode
84 @cindex Shell-script mode
85 @cindex Delphi mode
86 @cindex PostScript mode
87 @cindex Conf mode
88 @cindex DNS mode
89 The existing programming language major modes include Lisp, Scheme
90 (a variant of Lisp) and the Scheme-based DSSSL expression language,
91 Ada, ASM, AWK, C, C++, Delphi (Object Pascal), Fortran, Icon, IDL
92 (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s companion for font
93 creation), Modula2, Objective-C, Octave, Pascal, Perl, Pike,
94 PostScript, Prolog, Python, Simula, Tcl, and VHDL. An alternative
95 mode for Perl is called CPerl mode. Modes are available for the
96 scripting languages of the common GNU and Unix shells, VMS DCL, and
97 MS-DOS/MS-Windows @samp{BAT} files. There are also major modes for
98 editing makefiles, DNS master files, and various sorts of
99 configuration files.
100
101 @kindex DEL @r{(programming modes)}
102 @findex c-electric-backspace
103 In most programming languages, indentation should vary from line to
104 line to illustrate the structure of the program. So the major modes
105 for programming languages arrange for @key{TAB} to update the
106 indentation of the current line (@pxref{Program Indent}). They also
107 rebind @key{DEL} to treat a tab as if it were the equivalent number of
108 spaces; this lets you delete one column of indentation without
109 worrying whether the whitespace consists of spaces or tabs. Use
110 @kbd{C-b C-d} to delete a tab character before point, in these modes.
111
112 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
113 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL/Pike/AWK
114 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
115 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). For Fortran
116 mode, see
117 @iftex
118 @ref{Fortran,,, emacs-xtra, Specialized Emacs Features}.
119 @end iftex
120 @ifnottex
121 @ref{Fortran}.
122 @end ifnottex
123
124 @cindex mode hook
125 @vindex c-mode-hook
126 @vindex lisp-mode-hook
127 @vindex emacs-lisp-mode-hook
128 @vindex lisp-interaction-mode-hook
129 @vindex scheme-mode-hook
130 Turning on a major mode runs a normal hook called the @dfn{mode
131 hook}, which is the value of a Lisp variable. Each major mode has a
132 mode hook, and the hook's name is always made from the mode command's
133 name by adding @samp{-hook}. For example, turning on C mode runs the
134 hook @code{c-mode-hook}, while turning on Lisp mode runs the hook
135 @code{lisp-mode-hook}. The purpose of the mode hook is to give you a
136 place to set up customizations for that major mode. @xref{Hooks}.
137
138 @node Defuns
139 @section Top-Level Definitions, or Defuns
140
141 In Emacs, a major definition at the top level in the buffer, such as
142 a function, is called a @dfn{defun}. The name comes from Lisp, but in
143 Emacs we use it for all languages.
144
145 @menu
146 * Left Margin Paren:: An open-paren or similar opening delimiter
147 starts a defun if it is at the left margin.
148 * Moving by Defuns:: Commands to move over or mark a major definition.
149 * Imenu:: Making buffer indexes as menus.
150 * Which Function:: Which Function mode shows which function you are in.
151 @end menu
152
153 @node Left Margin Paren
154 @subsection Left Margin Convention
155
156 @cindex open-parenthesis in leftmost column
157 @cindex ( in leftmost column
158 Many programming-language modes assume by default that any opening
159 delimiter found at the left margin is the start of a top-level
160 definition, or defun. Therefore, @strong{don't put an opening
161 delimiter at the left margin unless it should have that significance}.
162 For instance, never put an open-parenthesis at the left margin in a
163 Lisp file unless it is the start of a top-level list.
164
165 The convention speeds up many Emacs operations, which would
166 otherwise have to scan back to the beginning of the buffer to analyze
167 the syntax of the code.
168
169 If you don't follow this convention, not only will you have trouble
170 when you explicitly use the commands for motion by defuns; other
171 features that use them will also give you trouble. This includes the
172 indentation commands (@pxref{Program Indent}) and Font Lock mode
173 (@pxref{Font Lock}).
174
175 The most likely problem case is when you want an opening delimiter
176 at the start of a line inside a string. To avoid trouble, put an
177 escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some
178 other Lisp dialects) before the opening delimiter. This will not
179 affect the contents of the string, but will prevent that opening
180 delimiter from starting a defun. Here's an example:
181
182 @example
183 (insert "Foo:
184 \(bar)
185 ")
186 @end example
187
188 To help you catch violations of this convention, Font Lock mode
189 highlights confusing opening delimiters (those that ought to be
190 quoted) in bold red.
191
192 If you need to override this convention, you can do so by setting
193 this user option:
194
195 @defvar open-paren-in-column-0-is-defun-start
196 If this user option is set to @code{t} (the default), opening
197 parentheses or braces at column zero always start defuns. When it's
198 @code{nil}, defuns are found by searching for parens or braces at the
199 outermost level.
200 @end defvar
201
202 Usually, you should leave this option at its default value of
203 @code{t}. If your buffer contains parentheses or braces in column
204 zero which don't start defuns, and it is somehow impractical to remove
205 these parentheses or braces, it might be helpful to set the option to
206 @code{nil}. Be aware that this might make scrolling and display in
207 large buffers quite sluggish. Furthermore, the parentheses and braces
208 must be correctly matched throughout the buffer for it to work
209 properly.
210
211 @node Moving by Defuns
212 @subsection Moving by Defuns
213 @cindex defuns
214
215 These commands move point or set up the region based on top-level
216 major definitions, also called @dfn{defuns}.
217
218 @table @kbd
219 @item C-M-a
220 Move to beginning of current or preceding defun
221 (@code{beginning-of-defun}).
222 @item C-M-e
223 Move to end of current or following defun (@code{end-of-defun}).
224 @item C-M-h
225 Put region around whole current or following defun (@code{mark-defun}).
226 @end table
227
228 @cindex move to beginning or end of function
229 @cindex function, move to beginning or end
230 @kindex C-M-a
231 @kindex C-M-e
232 @kindex C-M-h
233 @findex beginning-of-defun
234 @findex end-of-defun
235 @findex mark-defun
236 The commands to move to the beginning and end of the current defun
237 are @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e}
238 (@code{end-of-defun}). If you repeat one of these commands, or use a
239 positive numeric argument, each repetition moves to the next defun in
240 the direction of motion.
241
242 @kbd{C-M-a} with a negative argument @minus{}@var{n} moves forward
243 @var{n} times to the next beginning of a defun. This is not exactly
244 the same place that @kbd{C-M-e} with argument @var{n} would move to;
245 the end of this defun is not usually exactly the same place as the
246 beginning of the following defun. (Whitespace, comments, and perhaps
247 declarations can separate them.) Likewise, @kbd{C-M-e} with a
248 negative argument moves back to an end of a defun, which is not quite
249 the same as @kbd{C-M-a} with a positive argument.
250
251 @kindex C-M-h @r{(C mode)}
252 @findex c-mark-function
253 To operate on the current defun, use @kbd{C-M-h}
254 (@code{mark-defun}), which sets the mark at the end of the current
255 defun and puts point at its beginning. @xref{Marking Objects}. This
256 is the easiest way to get ready to kill the defun in order to move it
257 to a different place in the file. If you use the command while point
258 is between defuns, it uses the following defun. If you use the
259 command while the mark is already active, it sets the mark but does
260 not move point; furthermore, each successive use of @kbd{C-M-h}
261 extends the end of the region to include one more defun.
262
263 In C mode, @kbd{C-M-h} runs the function @code{c-mark-function},
264 which is almost the same as @code{mark-defun}; the difference is that
265 it backs up over the argument declarations, function name and returned
266 data type so that the entire C function is inside the region. This is
267 an example of how major modes adjust the standard key bindings so that
268 they do their standard jobs in a way better fitting a particular
269 language. Other major modes may replace any or all of these key
270 bindings for that purpose.
271
272 @node Imenu
273 @subsection Imenu
274 @cindex index of buffer definitions
275 @cindex buffer definitions index
276
277 The Imenu facility offers a way to find the major definitions in
278 a file by name. It is also useful in text formatter major modes,
279 where it treats each chapter, section, etc., as a definition.
280 (@xref{Tags}, for a more powerful feature that handles multiple files
281 together.)
282
283 @findex imenu
284 If you type @kbd{M-x imenu}, it reads the name of a definition using
285 the minibuffer, then moves point to that definition. You can use
286 completion to specify the name; the command always displays the whole
287 list of valid names.
288
289 @findex imenu-add-menubar-index
290 Alternatively, you can bind the command @code{imenu} to a mouse
291 click. Then it displays mouse menus for you to select a definition
292 name. You can also add the buffer's index to the menu bar by calling
293 @code{imenu-add-menubar-index}. If you want to have this menu bar
294 item available for all buffers in a certain major mode, you can do
295 this by adding @code{imenu-add-menubar-index} to its mode hook. But
296 if you have done that, you will have to wait a little while each time
297 you visit a file in that mode, while Emacs finds all the definitions
298 in that buffer.
299
300 @vindex imenu-auto-rescan
301 When you change the contents of a buffer, if you add or delete
302 definitions, you can update the buffer's index based on the
303 new contents by invoking the @samp{*Rescan*} item in the menu.
304 Rescanning happens automatically if you set @code{imenu-auto-rescan} to
305 a non-@code{nil} value. There is no need to rescan because of small
306 changes in the text.
307
308 @vindex imenu-sort-function
309 You can customize the way the menus are sorted by setting the
310 variable @code{imenu-sort-function}. By default, names are ordered as
311 they occur in the buffer; if you want alphabetic sorting, use the
312 symbol @code{imenu--sort-by-name} as the value. You can also
313 define your own comparison function by writing Lisp code.
314
315 Imenu provides the information to guide Which Function mode
316 @ifnottex
317 (@pxref{Which Function}).
318 @end ifnottex
319 @iftex
320 (see below).
321 @end iftex
322 The Speedbar can also use it (@pxref{Speedbar}).
323
324 @node Which Function
325 @subsection Which Function Mode
326 @cindex current function name in mode line
327
328 Which Function mode is a minor mode that displays the current
329 function name in the mode line, updating it as you move around in a
330 buffer.
331
332 @findex which-function-mode
333 @vindex which-func-modes
334 To either enable or disable Which Function mode, use the command
335 @kbd{M-x which-function-mode}. This command applies to all buffers,
336 both existing ones and those yet to be created. However, it takes
337 effect only in certain major modes, those listed in the value of
338 @code{which-func-modes}. If the value of @code{which-func-modes} is
339 @code{t} rather than a list of modes, then Which Function mode applies
340 to all major modes that know how to support it---in other words, all
341 the major modes that support Imenu.
342
343 @node Program Indent
344 @section Indentation for Programs
345 @cindex indentation for programs
346
347 The best way to keep a program properly indented is to use Emacs to
348 reindent it as you change it. Emacs has commands to indent either a
349 single line, a specified number of lines, or all of the lines inside a
350 single parenthetical grouping.
351
352 @menu
353 * Basic Indent:: Indenting a single line.
354 * Multi-line Indent:: Commands to reindent many lines at once.
355 * Lisp Indent:: Specifying how each Lisp function should be indented.
356 * C Indent:: Extra features for indenting C and related modes.
357 * Custom C Indent:: Controlling indentation style for C and related modes.
358 @end menu
359
360 @cindex pretty-printer
361 Emacs also provides a Lisp pretty-printer in the library @code{pp}.
362 This program reformats a Lisp object with indentation chosen to look nice.
363
364 @node Basic Indent
365 @subsection Basic Program Indentation Commands
366
367 The basic indentation commands indent a single line according to the
368 usual conventions of the language you are editing.
369
370 @table @kbd
371 @item @key{TAB}
372 Adjust indentation of current line.
373 @item C-j
374 Insert a newline, then adjust indentation of following line
375 (@code{newline-and-indent}).
376 @end table
377
378 @kindex TAB @r{(programming modes)}
379 @findex c-indent-command
380 @findex indent-line-function
381 @findex indent-for-tab-command
382 The basic indentation command is @key{TAB}. In any
383 programming-language major mode, @key{TAB} gives the current line the
384 correct indentation as determined from the previous lines. It does
385 this by inserting or deleting whitespace at the beginning of the
386 current line. If point was inside the whitespace at the beginning of
387 the line, @key{TAB} puts it at the end of that whitespace; otherwise,
388 @key{TAB} keeps point fixed with respect to the characters around it.
389 If the region is active (@pxref{Mark}), @key{TAB} indents every line
390 within the region instead of just the current line. The function that
391 @key{TAB} runs depends on the major mode; for instance, it is
392 @code{c-indent-line-or-region} in C mode. Each function is aware of
393 the syntax and conventions for its particular language.
394
395 Use @kbd{C-q @key{TAB}} to insert a tab character at point.
396
397 @kindex C-j
398 @findex newline-and-indent
399 When entering lines of new code, use @kbd{C-j}
400 (@code{newline-and-indent}), which inserts a newline and then adjusts
401 indentation after it. (It also deletes any trailing whitespace which
402 remains before the new newline.) For instance, @kbd{C-j} at the end
403 of a line creates a blank line with appropriate indentation. In
404 programming language modes, it is equivalent to @key{RET} @key{TAB}.
405
406 When Emacs indents a line that starts within a parenthetical
407 grouping, it usually places the start of the line under the preceding
408 line within the group, or under the text after the parenthesis. If
409 you manually give one of these lines a nonstandard indentation, the
410 lines below will tend to follow it. This behavior is convenient in
411 cases where you have overridden the standard result of @key{TAB}
412 indentation (e.g., for aesthetic purposes).
413
414 Many programming-language modes assume that an open-parenthesis,
415 open-brace or other opening delimiter at the left margin is the start
416 of a function. This assumption speeds up indentation commands. If
417 the text you are editing contains opening delimiters in column zero
418 that aren't the beginning of a functions---even if these delimiters
419 occur inside strings or comments---then you must set
420 @code{open-paren-in-column-0-is-defun-start}. @xref{Left Margin
421 Paren}.
422
423 Normally, Emacs indents lines using an ``optimal'' mix of tab and
424 space characters. If you want Emacs to use spaces only, set
425 @code{indent-tabs-mode} (@pxref{Just Spaces}).
426
427 @node Multi-line Indent
428 @subsection Indenting Several Lines
429
430 Sometimes, you may want to reindent several lines of code at a time.
431 One way to do this is to use the mark; when the mark is active and the
432 region is non-empty, @key{TAB} indents every line within the region.
433 In addition, Emacs provides several other commands for indenting large
434 chunks of code:
435
436 @table @kbd
437 @item C-M-q
438 Reindent all the lines within one parenthetical grouping.
439 @item C-M-\
440 Reindent all lines in the region (@code{indent-region}).
441 @item C-u @key{TAB}
442 Shift an entire parenthetical grouping rigidly sideways so that its
443 first line is properly indented.
444 @item M-x indent-code-rigidly
445 Shift all the lines in the region rigidly sideways, but do not alter
446 lines that start inside comments and strings.
447 @end table
448
449 @kindex C-M-q
450 @findex indent-pp-sexp
451 To reindent the contents of a single parenthetical grouping,
452 position point before the beginning of the grouping and type
453 @kbd{C-M-q}. This changes the relative indentation within the
454 grouping, without affecting its overall indentation (i.e., the
455 indentation of the line where the grouping starts). The function that
456 @kbd{C-M-q} runs depends on the major mode; it is
457 @code{indent-pp-sexp} in Lisp mode, @code{c-indent-exp} in C mode,
458 etc. To correct the overall indentation as well, type @key{TAB}
459 first.
460
461 @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to the region.
462 This is useful when Transient Mark mode is disabled (@pxref{Persistent
463 Mark}), because in that case @key{TAB} does not act on the region.
464
465 @kindex C-u TAB
466 If you like the relative indentation within a grouping but not the
467 indentation of its first line, move point to that first line and type
468 @kbd{C-u @key{TAB}}. In Lisp, C, and some other major modes,
469 @key{TAB} with a numeric argument reindents the current line as usual,
470 then reindents by the same amount all the lines in the parenthetical
471 grouping starting on the current line. It is clever, though, and does
472 not alter lines that start inside strings. Neither does it alter C
473 preprocessor lines when in C mode, but it does reindent any
474 continuation lines that may be attached to them.
475
476 @findex indent-code-rigidly
477 The command @kbd{M-x indent-code-rigidly} rigidly shifts all the
478 lines in the region sideways, like @code{indent-rigidly} does
479 (@pxref{Indentation Commands}). It doesn't alter the indentation of
480 lines that start inside a string, unless the region also starts inside
481 that string. The prefix arg specifies the number of columns to
482 indent.
483
484 @node Lisp Indent
485 @subsection Customizing Lisp Indentation
486 @cindex customizing Lisp indentation
487
488 The indentation pattern for a Lisp expression can depend on the function
489 called by the expression. For each Lisp function, you can choose among
490 several predefined patterns of indentation, or define an arbitrary one with
491 a Lisp program.
492
493 The standard pattern of indentation is as follows: the second line of the
494 expression is indented under the first argument, if that is on the same
495 line as the beginning of the expression; otherwise, the second line is
496 indented underneath the function name. Each following line is indented
497 under the previous line whose nesting depth is the same.
498
499 @vindex lisp-indent-offset
500 If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides
501 the usual indentation pattern for the second line of an expression, so that
502 such lines are always indented @code{lisp-indent-offset} more columns than
503 the containing list.
504
505 @vindex lisp-body-indent
506 Certain functions override the standard pattern. Functions whose
507 names start with @code{def} treat the second lines as the start of
508 a @dfn{body}, by indenting the second line @code{lisp-body-indent}
509 additional columns beyond the open-parenthesis that starts the
510 expression.
511
512 @cindex @code{lisp-indent-function} property
513 You can override the standard pattern in various ways for individual
514 functions, according to the @code{lisp-indent-function} property of
515 the function name. Normally you would use this for macro definitions
516 and specify it using the @code{declare} construct (@pxref{Defining
517 Macros,,, elisp, the Emacs Lisp Reference Manual}).
518
519 @node C Indent
520 @subsection Commands for C Indentation
521
522 Here are special features for indentation in C mode and related modes:
523
524 @table @code
525 @item C-c C-q
526 @kindex C-c C-q @r{(C mode)}
527 @findex c-indent-defun
528 Reindent the current top-level function definition or aggregate type
529 declaration (@code{c-indent-defun}).
530
531 @item C-M-q
532 @kindex C-M-q @r{(C mode)}
533 @findex c-indent-exp
534 Reindent each line in the balanced expression that follows point
535 (@code{c-indent-exp}). A prefix argument inhibits warning messages
536 about invalid syntax.
537
538 @item @key{TAB}
539 @findex c-indent-command
540 Reindent the current line, and/or in some cases insert a tab character
541 (@code{c-indent-command}).
542
543 @vindex c-tab-always-indent
544 If @code{c-tab-always-indent} is @code{t}, this command always reindents
545 the current line and does nothing else. This is the default.
546
547 If that variable is @code{nil}, this command reindents the current line
548 only if point is at the left margin or in the line's indentation;
549 otherwise, it inserts a tab (or the equivalent number of spaces,
550 if @code{indent-tabs-mode} is @code{nil}).
551
552 Any other value (not @code{nil} or @code{t}) means always reindent the
553 line, and also insert a tab if within a comment or a string.
554 @end table
555
556 To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This
557 first selects the whole buffer as the region, then reindents that
558 region.
559
560 To reindent the current block, use @kbd{C-M-u C-M-q}. This moves
561 to the front of the block and then reindents it all.
562
563 @node Custom C Indent
564 @subsection Customizing C Indentation
565 @cindex style (for indentation)
566
567 C mode and related modes use a flexible mechanism for customizing
568 indentation. C mode indents a source line in two steps: first it
569 classifies the line syntactically according to its contents and
570 context; second, it determines the indentation offset associated by
571 your selected @dfn{style} with the syntactic construct and adds this
572 onto the indentation of the @dfn{anchor statement}.
573
574 @table @kbd
575 @item C-c . @key{RET} @var{style} @key{RET}
576 Select a predefined style @var{style} (@code{c-set-style}).
577 @end table
578
579 A @dfn{style} is a named collection of customizations that can be
580 used in C mode and the related modes. @ref{Styles,,, ccmode, The CC
581 Mode Manual}, for a complete description. Emacs comes with several
582 predefined styles, including @code{gnu}, @code{k&r}, @code{bsd},
583 @code{stroustrup}, @code{linux}, @code{python}, @code{java},
584 @code{whitesmith}, @code{ellemtel}, and @code{awk}. Some of these
585 styles are primarily intended for one language, but any of them can be
586 used with any of the languages supported by these modes. To find out
587 what a style looks like, select it and reindent some code, e.g., by
588 typing @key{C-M-q} at the start of a function definition.
589
590 @kindex C-c . @r{(C mode)}
591 @findex c-set-style
592 To choose a style for the current buffer, use the command @w{@kbd{C-c
593 .}}. Specify a style name as an argument (case is not significant).
594 This command affects the current buffer only, and it affects only
595 future invocations of the indentation commands; it does not reindent
596 the code already in the buffer. To reindent the whole buffer in the
597 new style, you can type @kbd{C-x h C-M-\}.
598
599 @vindex c-default-style
600 You can also set the variable @code{c-default-style} to specify the
601 default style for various major modes. Its value should be either the
602 style's name (a string) or an alist, in which each element specifies
603 one major mode and which indentation style to use for it. For
604 example,
605
606 @example
607 (setq c-default-style
608 '((java-mode . "java") (awk-mode . "awk") (other . "gnu")))
609 @end example
610
611 @noindent
612 specifies explicit choices for Java and AWK modes, and the default
613 @samp{gnu} style for the other C-like modes. (These settings are
614 actually the defaults.) This variable takes effect when you select
615 one of the C-like major modes; thus, if you specify a new default
616 style for Java mode, you can make it take effect in an existing Java
617 mode buffer by typing @kbd{M-x java-mode} there.
618
619 The @code{gnu} style specifies the formatting recommended by the GNU
620 Project for C; it is the default, so as to encourage use of our
621 recommended style.
622
623 @xref{Indentation Engine Basics,,, ccmode, the CC Mode Manual}, and
624 @ref{Customizing Indentation,,, ccmode, the CC Mode Manual}, for more
625 information on customizing indentation for C and related modes,
626 including how to override parts of an existing style and how to define
627 your own styles.
628
629 @node Parentheses
630 @section Commands for Editing with Parentheses
631
632 @findex check-parens
633 @cindex unbalanced parentheses and quotes
634 This section describes the commands and features that take advantage
635 of the parenthesis structure in a program, or help you keep it
636 balanced.
637
638 When talking about these facilities, the term ``parenthesis'' also
639 includes braces, brackets, or whatever delimiters are defined to match
640 in pairs. The major mode controls which delimiters are significant,
641 through the syntax table (@pxref{Syntax}). In Lisp, only parentheses
642 count; in C, these commands apply to braces and brackets too.
643
644 You can use @kbd{M-x check-parens} to find any unbalanced
645 parentheses and unbalanced string quotes in the buffer.
646
647 @menu
648 * Expressions:: Expressions with balanced parentheses.
649 * Moving by Parens:: Commands for moving up, down and across
650 in the structure of parentheses.
651 * Matching:: Insertion of a close-delimiter flashes matching open.
652 @end menu
653
654 @node Expressions
655 @subsection Expressions with Balanced Parentheses
656
657 @cindex sexp
658 @cindex expression
659 @cindex balanced expression
660 These commands deal with balanced expressions, also called
661 @dfn{sexps}@footnote{The word ``sexp'' is used to refer to an
662 expression in Lisp.}.
663
664 @table @kbd
665 @item C-M-f
666 Move forward over a balanced expression (@code{forward-sexp}).
667 @item C-M-b
668 Move backward over a balanced expression (@code{backward-sexp}).
669 @item C-M-k
670 Kill balanced expression forward (@code{kill-sexp}).
671 @item C-M-t
672 Transpose expressions (@code{transpose-sexps}).
673 @item C-M-@@
674 @itemx C-M-@key{SPC}
675 Put mark after following expression (@code{mark-sexp}).
676 @end table
677
678 Each programming language major mode customizes the definition of
679 balanced expressions to suit that language. Balanced expressions
680 typically include symbols, numbers, and string constants, as well as
681 any pair of matching delimiters and their contents. Some languages
682 have obscure forms of expression syntax that nobody has bothered to
683 implement in Emacs.
684
685 @cindex Control-Meta
686 By convention, the keys for these commands are all Control-Meta
687 characters. They usually act on expressions just as the corresponding
688 Meta characters act on words. For instance, the command @kbd{C-M-b}
689 moves backward over a balanced expression, just as @kbd{M-b} moves
690 back over a word.
691
692 @kindex C-M-f
693 @kindex C-M-b
694 @findex forward-sexp
695 @findex backward-sexp
696 To move forward over a balanced expression, use @kbd{C-M-f}
697 (@code{forward-sexp}). If the first significant character after point
698 is an opening delimiter (@samp{(} in Lisp; @samp{(}, @samp{[} or
699 @samp{@{} in C), @kbd{C-M-f} moves past the matching closing
700 delimiter. If the character begins a symbol, string, or number,
701 @kbd{C-M-f} moves over that.
702
703 The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a
704 balanced expression. The detailed rules are like those above for
705 @kbd{C-M-f}, but with directions reversed. If there are prefix
706 characters (single-quote, backquote and comma, in Lisp) preceding the
707 expression, @kbd{C-M-b} moves back over them as well. The balanced
708 expression commands move across comments as if they were whitespace,
709 in most modes.
710
711 @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the
712 specified number of times; with a negative argument, it moves in the
713 opposite direction.
714
715 @cindex killing expressions
716 @kindex C-M-k
717 @findex kill-sexp
718 Killing a whole balanced expression can be done with @kbd{C-M-k}
719 (@code{kill-sexp}). @kbd{C-M-k} kills the characters that @kbd{C-M-f}
720 would move over.
721
722 @cindex transposition of expressions
723 @kindex C-M-t
724 @findex transpose-sexps
725 A somewhat random-sounding command which is nevertheless handy is
726 @kbd{C-M-t} (@code{transpose-sexps}), which drags the previous
727 balanced expression across the next one. An argument serves as a
728 repeat count, moving the previous expression over that many following
729 ones. A negative argument drags the previous balanced expression
730 backwards across those before it (thus canceling out the effect of
731 @kbd{C-M-t} with a positive argument). An argument of zero, rather
732 than doing nothing, transposes the balanced expressions ending at or
733 after point and the mark.
734
735 @kindex C-M-@@
736 @kindex C-M-@key{SPC}
737 @findex mark-sexp
738 To set the region around the next balanced expression in the buffer,
739 use @kbd{C-M-@key{SPC}} (@code{mark-sexp}), which sets mark at the
740 same place that @kbd{C-M-f} would move to. @kbd{C-M-@key{SPC}} treats
741 numeric arguments in the same way as @kbd{C-M-f}; in particular, a
742 negative argument puts the mark at the beginning of the previous
743 balanced expression. The alias @kbd{C-M-@@} is equivalent to
744 @kbd{C-M-@key{SPC}}. While the mark is active, each successive use of
745 @kbd{C-M-@key{SPC}} extends the region by shifting the mark by one
746 sexp.
747
748 In languages that use infix operators, such as C, it is not possible
749 to recognize all balanced expressions as such because there can be
750 multiple possibilities at a given position. For example, C mode does
751 not treat @samp{foo + bar} as a single expression, even though it
752 @emph{is} one C expression; instead, it recognizes @samp{foo} as one
753 expression and @samp{bar} as another, with the @samp{+} as punctuation
754 between them. Both @samp{foo + bar} and @samp{foo} are legitimate
755 choices for ``the expression following point'' when point is at the
756 @samp{f}, so the expression commands must perforce choose one or the
757 other to operate on. Note that @samp{(foo + bar)} is recognized as a
758 single expression in C mode, because of the parentheses.
759
760 @node Moving by Parens
761 @subsection Moving in the Parenthesis Structure
762
763 @cindex parenthetical groupings
764 @cindex parentheses, moving across
765 @cindex matching parenthesis and braces, moving to
766 @cindex braces, moving across
767 @cindex list commands
768
769 The Emacs commands for handling parenthetical groupings see nothing
770 except parentheses (or whatever characters must balance in the
771 language you are working with). They ignore strings and comments
772 (including any parentheses within them) and ignore parentheses quoted
773 by an escape character. They are mainly intended for editing
774 programs, but can be useful for editing any text that has parentheses.
775 They are sometimes called ``list'' commands because in Lisp these
776 groupings are lists.
777
778 These commands assume that the starting point is not inside a string
779 or a comment. Sometimes you can invoke them usefully from one of
780 these places (for example, when you have a parenthesised clause in a
781 comment) but this is unreliable.
782
783 @table @kbd
784 @item C-M-n
785 Move forward over a parenthetical group (@code{forward-list}).
786 @item C-M-p
787 Move backward over a parenthetical group (@code{backward-list}).
788 @item C-M-u
789 Move up in parenthesis structure (@code{backward-up-list}).
790 @item C-M-d
791 Move down in parenthesis structure (@code{down-list}).
792 @end table
793
794 @kindex C-M-n
795 @kindex C-M-p
796 @findex forward-list
797 @findex backward-list
798 The ``list'' commands @kbd{C-M-n} (@code{forward-list}) and
799 @kbd{C-M-p} (@code{backward-list}) move forward or backward over one
800 (or @var{n}) parenthetical groupings.
801
802 @kindex C-M-u
803 @findex backward-up-list
804 @kbd{C-M-n} and @kbd{C-M-p} try to stay at the same level in the
805 parenthesis structure. To move @emph{up} one (or @var{n}) levels, use
806 @kbd{C-M-u} (@code{backward-up-list}). @kbd{C-M-u} moves backward up
807 past one unmatched opening delimiter. A positive argument serves as a
808 repeat count; a negative argument reverses the direction of motion, so
809 that the command moves forward and up one or more levels.
810
811 @kindex C-M-d
812 @findex down-list
813 To move @emph{down} in the parenthesis structure, use @kbd{C-M-d}
814 (@code{down-list}). In Lisp mode, where @samp{(} is the only opening
815 delimiter, this is nearly the same as searching for a @samp{(}. An
816 argument specifies the number of levels to go down.
817
818 @node Matching
819 @subsection Automatic Display Of Matching Parentheses
820 @cindex matching parentheses
821 @cindex parentheses, displaying matches
822
823 The Emacs parenthesis-matching feature is designed to show
824 automatically how parentheses (and other matching delimiters) match in
825 the text. Whenever you type a self-inserting character that is a
826 closing delimiter, the cursor moves momentarily to the location of the
827 matching opening delimiter, provided that is on the screen. If it is
828 not on the screen, Emacs displays some of the text near it in the echo
829 area. Either way, you can tell which grouping you are closing off.
830
831 If the opening delimiter and closing delimiter are mismatched---such
832 as in @samp{[x)}---a warning message is displayed in the echo area.
833
834 @vindex blink-matching-paren
835 @vindex blink-matching-paren-distance
836 @vindex blink-matching-delay
837 Three variables control parenthesis match display:
838
839 @code{blink-matching-paren} turns the feature on or off: @code{nil}
840 disables it, but the default is @code{t} to enable match display.
841
842 @code{blink-matching-delay} says how many seconds to leave the
843 cursor on the matching opening delimiter, before bringing it back to
844 the real location of point; the default is 1, but on some systems it
845 is useful to specify a fraction of a second.
846
847 @code{blink-matching-paren-distance} specifies how many characters
848 back to search to find the matching opening delimiter. If the match
849 is not found in that distance, scanning stops, and nothing is displayed.
850 This is to prevent the scan for the matching delimiter from wasting
851 lots of time when there is no match. The default is 25600.
852
853 @cindex Show Paren mode
854 @cindex highlighting matching parentheses
855 @findex show-paren-mode
856 Show Paren mode provides a more powerful kind of automatic matching.
857 Whenever point is before an opening delimiter or after a closing
858 delimiter, both that delimiter and its opposite delimiter are
859 highlighted. Use the command @kbd{M-x show-paren-mode} to enable or
860 disable this mode.
861
862 Show Paren mode uses the faces @code{show-paren-match} and
863 @code{show-paren-mismatch} to highlight parentheses; you can customize
864 them to control how highlighting looks. @xref{Face Customization}.
865
866 @node Comments
867 @section Manipulating Comments
868 @cindex comments
869
870 Because comments are such an important part of programming, Emacs
871 provides special commands for editing and inserting comments. It can
872 also do spell checking on comments with Flyspell Prog mode
873 (@pxref{Spelling}).
874
875 @menu
876 * Comment Commands:: Inserting, killing, and aligning comments.
877 * Multi-Line Comments:: Commands for adding and editing multi-line comments.
878 * Options for Comments::Customizing the comment features.
879 @end menu
880
881 @node Comment Commands
882 @subsection Comment Commands
883 @cindex indentation for comments
884 @cindex alignment for comments
885
886 The commands in this table insert, kill and align comments:
887
888 @table @asis
889 @item @kbd{M-;}
890 Insert or realign comment on current line; alternatively, comment or
891 uncomment the region (@code{comment-dwim}).
892 @item @kbd{C-u M-;}
893 Kill comment on current line (@code{comment-kill}).
894 @item @kbd{C-x ;}
895 Set comment column (@code{comment-set-column}).
896 @item @kbd{C-M-j}
897 @itemx @kbd{M-j}
898 Like @key{RET} followed by inserting and aligning a comment
899 (@code{comment-indent-new-line}). @xref{Multi-Line Comments}.
900 @item @kbd{M-x comment-region}
901 @itemx @kbd{C-c C-c} (in C-like modes)
902 Add or remove comment delimiters on all the lines in the region.
903 @end table
904
905 @kindex M-;
906 @findex comment-dwim
907 The command to create or align a comment is @kbd{M-;}
908 (@code{comment-dwim}). The word ``dwim'' is an acronym for ``Do What
909 I Mean''; it indicates that this command can be used for many
910 different jobs relating to comments, depending on the situation where
911 you use it.
912
913 If there is no comment already on the line, @kbd{M-;} inserts a new
914 comment, aligned at a specific column called the @dfn{comment column}.
915 The new comment begins with the string Emacs thinks comments should
916 start with (the value of @code{comment-start}; see below). Point is
917 after that string, so you can insert the text of the comment right
918 away. If the major mode has specified a string to terminate comments,
919 @kbd{M-;} inserts that after point, to keep the syntax valid.
920
921 If the text of the line extends past the comment column, this
922 command aligns the comment start string to a suitable boundary
923 (usually, at least one space is inserted).
924
925 You can also use @kbd{M-;} to align an existing comment. If a line
926 already contains the comment-start string, @kbd{M-;} realigns it to
927 the conventional alignment and moves point after it. (Exception:
928 comments starting in column 0 are not moved.) Even when an existing
929 comment is properly aligned, @kbd{M-;} is still useful for moving
930 directly to the start of the text inside the comment.
931
932 @findex comment-kill
933 @kindex C-u M-;
934 @kbd{C-u M-;} kills any comment on the current line, along with the
935 whitespace before it. To reinsert the comment on another line, move
936 to the end of that line, do @kbd{C-y}, and then do @kbd{M-;} to
937 realign it.
938
939 Note that @kbd{C-u M-;} is not a distinct key; it is @kbd{M-;}
940 (@code{comment-dwim}) with a prefix argument. That command is
941 programmed so that when it receives a prefix argument it calls
942 @code{comment-kill}. However, @code{comment-kill} is a valid command
943 in its own right, and you can bind it directly to a key if you wish.
944
945 When a region is active, @kbd{M-;} either adds or removes comment
946 delimiters on each line of the region. @xref{Mark}. If every line in
947 the region is a comment, it removes comment delimiters from each;
948 otherwise, it adds comment delimiters to each. You can also use the
949 commands @code{comment-region} and @code{uncomment-region} to do these
950 jobs (@pxref{Multi-Line Comments}). A prefix argument used in these
951 circumstances specifies how many comment delimiters to add or how many
952 to delete.
953
954 Some major modes have special rules for aligning certain kinds of
955 comments in certain contexts. For example, in Lisp code, comments which
956 start with two semicolons are indented as if they were lines of code,
957 instead of at the comment column. Comments which start with three
958 semicolons are supposed to start at the left margin and are often used
959 for sectioning purposes. Emacs understands
960 these conventions by indenting a double-semicolon comment using @key{TAB},
961 and by not changing the indentation of a triple-semicolon comment at all.
962
963 @example
964 ;; This function is just an example.
965 ;;; Here either two or three semicolons are appropriate.
966 (defun foo (x)
967 ;;; And now, the first part of the function:
968 ;; The following line adds one.
969 (1+ x)) ; This line adds one.
970 @end example
971
972 For C-like modes, you can configure the exact effect of @kbd{M-;} by
973 setting the variables @code{c-indent-comment-alist} and
974 @code{c-indent-comments-syntactically-p}. For example, on a line
975 ending in a closing brace, @kbd{M-;} puts the comment one space after
976 the brace rather than at @code{comment-column}. For full details see
977 @ref{Comment Commands,,, ccmode, The CC Mode Manual}.
978
979 @node Multi-Line Comments
980 @subsection Multiple Lines of Comments
981
982 @kindex C-M-j
983 @kindex M-j
984 @cindex blank lines in programs
985 @findex comment-indent-new-line
986
987 If you are typing a comment and wish to continue it on another line,
988 you can use the command @kbd{C-M-j} or @kbd{M-j}
989 (@code{comment-indent-new-line}). If @code{comment-multi-line}
990 (@pxref{Options for Comments}) is non-@code{nil}, it moves to a new
991 line within the comment. Otherwise it closes the comment and starts a
992 new comment on a new line. When Auto Fill mode is on, going past the
993 fill column while typing a comment causes the comment to be continued
994 in just this fashion.
995
996 @kindex C-c C-c (C mode)
997 @findex comment-region
998 To turn existing lines into comment lines, use the @kbd{M-x
999 comment-region} command (or type @kbd{C-c C-c} in C-like modes). It
1000 adds comment delimiters to the lines that start in the region, thus
1001 commenting them out. With a negative argument, it does the
1002 opposite---it deletes comment delimiters from the lines in the region.
1003
1004 With a positive argument, @code{comment-region} duplicates the last
1005 character of the comment start sequence it adds; the argument
1006 specifies how many copies of the character to insert. Thus, in Lisp
1007 mode, @kbd{C-u 2 M-x comment-region} adds @samp{;;} to each line.
1008 Duplicating the comment delimiter is a way of calling attention to the
1009 comment. It can also affect how the comment is aligned or indented.
1010 In Lisp, for proper indentation, you should use an argument of two or
1011 three, if between defuns; if within a defun, it must be three.
1012
1013 You can configure C Mode such that when you type a @samp{/} at the
1014 start of a line in a multi-line block comment, this closes the
1015 comment. Enable the @code{comment-close-slash} clean-up for this.
1016 @xref{Clean-ups,,, ccmode, The CC Mode Manual}.
1017
1018 @node Options for Comments
1019 @subsection Options Controlling Comments
1020
1021 @vindex comment-column
1022 @kindex C-x ;
1023 @findex comment-set-column
1024 The @dfn{comment column}, the column at which Emacs tries to place
1025 comments, is stored in the variable @code{comment-column}. You can
1026 set it to a number explicitly. Alternatively, the command @kbd{C-x ;}
1027 (@code{comment-set-column}) sets the comment column to the column
1028 point is at. @kbd{C-u C-x ;} sets the comment column to match the
1029 last comment before point in the buffer, and then does a @kbd{M-;} to
1030 align the current line's comment under the previous one.
1031
1032 The variable @code{comment-column} is per-buffer: setting the variable
1033 in the normal fashion affects only the current buffer, but there is a
1034 default value which you can change with @code{setq-default}.
1035 @xref{Locals}. Many major modes initialize this variable for the
1036 current buffer.
1037
1038 @vindex comment-start-skip
1039 The comment commands recognize comments based on the regular
1040 expression that is the value of the variable @code{comment-start-skip}.
1041 Make sure this regexp does not match the null string. It may match more
1042 than the comment starting delimiter in the strictest sense of the word;
1043 for example, in C mode the value of the variable is
1044 @c This stops M-q from breaking the line inside that @code.
1045 @code{@w{"/\\*+ *\\|//+ *"}}, which matches extra stars and spaces
1046 after the @samp{/*} itself, and accepts C++ style comments also.
1047 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in
1048 the string, which is needed to deny the first star its special meaning
1049 in regexp syntax. @xref{Regexp Backslash}.)
1050
1051 @vindex comment-start
1052 @vindex comment-end
1053 When a comment command makes a new comment, it inserts the value of
1054 @code{comment-start} to begin it. The value of @code{comment-end} is
1055 inserted after point, so that it will follow the text that you will
1056 insert into the comment. When @code{comment-end} is non-empty, it
1057 should start with a space. For example, in C mode,
1058 @code{comment-start} has the value @w{@code{"/* "}} and
1059 @code{comment-end} has the value @w{@code{" */"}}.
1060
1061 @vindex comment-padding
1062 The variable @code{comment-padding} specifies how many spaces
1063 @code{comment-region} should insert on each line between the comment
1064 delimiter and the line's original text. The default is 1, to insert
1065 one space. @code{nil} means 0. Alternatively, @code{comment-padding}
1066 can hold the actual string to insert.
1067
1068 @vindex comment-multi-line
1069 The variable @code{comment-multi-line} controls how @kbd{C-M-j}
1070 (@code{indent-new-comment-line}) behaves when used inside a comment.
1071 Specifically, when @code{comment-multi-line} is @code{nil}, the
1072 command inserts a comment terminator, begins a new line, and finally
1073 inserts a comment starter. Otherwise it does not insert the
1074 terminator and starter, so it effectively continues the current
1075 comment across multiple lines. In languages that allow multi-line
1076 comments, the choice of value for this variable is a matter of taste.
1077 The default for this variable depends on the major mode.
1078
1079 @vindex comment-indent-function
1080 The variable @code{comment-indent-function} should contain a function
1081 that will be called to compute the alignment for a newly inserted
1082 comment or for aligning an existing comment. It is set differently by
1083 various major modes. The function is called with no arguments, but with
1084 point at the beginning of the comment, or at the end of a line if a new
1085 comment is to be inserted. It should return the column in which the
1086 comment ought to start. For example, in Lisp mode, the indent hook
1087 function bases its decision on how many semicolons begin an existing
1088 comment, and on the code in the preceding lines.
1089
1090 @node Documentation
1091 @section Documentation Lookup
1092
1093 Emacs provides several features you can use to look up the
1094 documentation of functions, variables and commands that you plan to
1095 use in your program.
1096
1097 @menu
1098 * Info Lookup:: Looking up library functions and commands
1099 in Info files.
1100 * Man Page:: Looking up man pages of library functions and commands.
1101 * Lisp Doc:: Looking up Emacs Lisp functions, etc.
1102 @end menu
1103
1104 @node Info Lookup
1105 @subsection Info Documentation Lookup
1106
1107 @findex info-lookup-symbol
1108 @findex info-lookup-file
1109 @kindex C-h S
1110 For major modes that apply to languages which have documentation in
1111 Info, you can use @kbd{C-h S} (@code{info-lookup-symbol}) to view the
1112 Info documentation for a symbol used in the program. You specify the
1113 symbol with the minibuffer; the default is the symbol appearing in the
1114 buffer at point. For example, in C mode this looks for the symbol in
1115 the C Library Manual. The command only works if the appropriate
1116 manual's Info files are installed.
1117
1118 The major mode determines where to look for documentation for the
1119 symbol---which Info files to look in, and which indices to search.
1120 You can also use @kbd{M-x info-lookup-file} to look for documentation
1121 for a file name.
1122
1123 If you use @kbd{C-h S} in a major mode that does not support it,
1124 it asks you to specify the ``symbol help mode.'' You should enter
1125 a command such as @code{c-mode} that would select a major
1126 mode which @kbd{C-h S} does support.
1127
1128 @node Man Page
1129 @subsection Man Page Lookup
1130
1131 @cindex manual page
1132 On Unix, the main form of on-line documentation was the @dfn{manual
1133 page} or @dfn{man page}. In the GNU operating system, we aim to
1134 replace man pages with better-organized manuals that you can browse
1135 with Info (@pxref{Misc Help}). This process is not finished, so it is
1136 still useful to read manual pages.
1137
1138 @findex manual-entry
1139 You can read the man page for an operating system command, library
1140 function, or system call, with the @kbd{M-x man} command. It
1141 runs the @code{man} program to format the man page; if the system
1142 permits, it runs @code{man} asynchronously, so that you can keep on
1143 editing while the page is being formatted. (On MS-DOS and MS-Windows
1144 3, you cannot edit while Emacs waits for @code{man} to finish.) The
1145 result goes in a buffer named @samp{*Man @var{topic}*}. These buffers
1146 use a special major mode, Man mode, that facilitates scrolling and
1147 jumping to other manual pages. For details, type @kbd{C-h m} while in
1148 a man page buffer.
1149
1150 @cindex sections of manual pages
1151 Each man page belongs to one of ten or more @dfn{sections}, each
1152 named by a digit or by a digit and a letter. Sometimes there are
1153 multiple man pages with the same name in different sections. To read
1154 a man page from a specific section, type
1155 @samp{@var{topic}(@var{section})} or @samp{@var{section} @var{topic}}
1156 when @kbd{M-x manual-entry} prompts for the topic. For example, to
1157 read the man page for the C library function @code{chmod} (as opposed
1158 to a command of the same name), type @kbd{M-x manual-entry @key{RET}
1159 chmod(2) @key{RET}}. (@code{chmod} is a system call, so it is in
1160 section @samp{2}.)
1161
1162 @vindex Man-switches
1163 If you do not specify a section, the results depend on how the
1164 @code{man} program works on your system. Some of them display only
1165 the first man page they find. Others display all man pages that have
1166 the specified name, so you can move between them with the @kbd{M-n}
1167 and @kbd{M-p} keys@footnote{On some systems, the @code{man} program
1168 accepts a @samp{-a} command-line option which tells it to display all
1169 the man pages for the specified topic. If you want this behavior, you
1170 can add this option to the value of the variable @code{Man-switches}.}.
1171 The mode line shows how many manual pages are present in the Man buffer.
1172
1173 @vindex Man-fontify-manpage-flag
1174 By default, Emacs highlights the text in man pages. For a long man
1175 page, highlighting can take substantial time. You can turn off
1176 highlighting of man pages by setting the variable
1177 @code{Man-fontify-manpage-flag} to @code{nil}.
1178
1179 @findex Man-fontify-manpage
1180 If you insert the text of a man page into an Emacs buffer in some
1181 other fashion, you can use the command @kbd{M-x Man-fontify-manpage} to
1182 perform the same conversions that @kbd{M-x manual-entry} does.
1183
1184 @findex woman
1185 @cindex manual pages, on MS-DOS/MS-Windows
1186 An alternative way of reading manual pages is the @kbd{M-x woman}
1187 command@footnote{The name of the command, @code{woman}, is an acronym
1188 for ``w/o (without) man,'' since it doesn't use the @code{man}
1189 program.}. Unlike @kbd{M-x man}, it does not run any external
1190 programs to format and display the man pages; instead it does the job
1191 in Emacs Lisp, so it works on systems such as MS-Windows, where the
1192 @code{man} program (and other programs it uses) are not generally
1193 available.
1194
1195 @kbd{M-x woman} prompts for a name of a manual page, and provides
1196 completion based on the list of manual pages that are installed on
1197 your machine; the list of available manual pages is computed
1198 automatically the first time you invoke @code{woman}. The word at
1199 point in the current buffer is used to suggest the default for the
1200 name the manual page.
1201
1202 With a numeric argument, @kbd{M-x woman} recomputes the list of the
1203 manual pages used for completion. This is useful if you add or delete
1204 manual pages.
1205
1206 If you type a name of a manual page and @kbd{M-x woman} finds that
1207 several manual pages by the same name exist in different sections, it
1208 pops up a window with possible candidates asking you to choose one of
1209 them.
1210
1211 For more information about setting up and using @kbd{M-x woman}, see
1212 @ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The WoMan
1213 Manual}.
1214
1215 @node Lisp Doc
1216 @subsection Emacs Lisp Documentation Lookup
1217
1218 As you edit Lisp code to be run in Emacs, you can use the commands
1219 @kbd{C-h f} (@code{describe-function}) and @kbd{C-h v}
1220 (@code{describe-variable}) to view documentation of functions and
1221 variables that you want to use. These commands use the minibuffer to
1222 read the name of a function or variable to document, and display the
1223 documentation in a window. Their default arguments are based on the
1224 code in the neighborhood of point. For @kbd{C-h f}, the default is
1225 the function called in the innermost list containing point. @kbd{C-h
1226 v} uses the symbol name around or adjacent to point as its default.
1227
1228 @cindex Eldoc mode
1229 @findex eldoc-mode
1230 A more automatic but less powerful method is Eldoc mode. This minor
1231 mode constantly displays in the echo area the argument list for the
1232 function being called at point. (In other words, it finds the
1233 function call that point is contained in, and displays the argument
1234 list of that function.) If point is over a documented variable, it
1235 shows the first line of the variable's docstring. Eldoc mode applies
1236 in Emacs Lisp and Lisp Interaction modes, and perhaps a few others
1237 that provide special support for looking up doc strings. Use the
1238 command @kbd{M-x eldoc-mode} to enable or disable this feature.
1239
1240 @node Hideshow
1241 @section Hideshow minor mode
1242
1243 @findex hs-minor-mode
1244 Hideshow minor mode provides selective display of portions of a
1245 program, known as @dfn{blocks}. You can use @kbd{M-x hs-minor-mode}
1246 to enable or disable this mode, or add @code{hs-minor-mode} to the
1247 mode hook for certain major modes in order to enable it automatically
1248 for those modes.
1249
1250 Just what constitutes a block depends on the major mode. In C mode
1251 or C++ mode, they are delimited by braces, while in Lisp mode and
1252 similar modes they are delimited by parentheses. Multi-line comments
1253 also count as blocks.
1254
1255 @findex hs-hide-all
1256 @findex hs-hide-block
1257 @findex hs-show-all
1258 @findex hs-show-block
1259 @findex hs-show-region
1260 @findex hs-hide-level
1261 @findex hs-minor-mode
1262 @kindex C-c @@ C-h
1263 @kindex C-c @@ C-s
1264 @kindex C-c @@ C-M-h
1265 @kindex C-c @@ C-M-s
1266 @kindex C-c @@ C-r
1267 @kindex C-c @@ C-l
1268 @kindex S-Mouse-2
1269 @table @kbd
1270 @item C-c @@ C-h
1271 Hide the current block (@code{hs-hide-block}).
1272 @item C-c @@ C-s
1273 Show the current block (@code{hs-show-block}).
1274 @item C-c @@ C-c
1275 Either hide or show the current block (@code{hs-toggle-hiding}).
1276 @item S-Mouse-2
1277 Either hide or show the block you click on (@code{hs-mouse-toggle-hiding}).
1278 @item C-c @@ C-M-h
1279 Hide all top-level blocks (@code{hs-hide-all}).
1280 @item C-c @@ C-M-s
1281 Show everything in the buffer (@code{hs-show-all}).
1282 @item C-c @@ C-l
1283 Hide all blocks @var{n} levels below this block
1284 (@code{hs-hide-level}).
1285 @end table
1286
1287 @vindex hs-hide-comments-when-hiding-all
1288 @vindex hs-isearch-open
1289 @vindex hs-special-modes-alist
1290 These variables exist for customizing Hideshow mode.
1291
1292 @table @code
1293 @item hs-hide-comments-when-hiding-all
1294 Non-@code{nil} says that @kbd{hs-hide-all} should hide comments too.
1295
1296 @item hs-isearch-open
1297 Specifies what kind of hidden blocks incremental search should make
1298 visible. The value should be one of these four symbols:
1299
1300 @table @code
1301 @item code
1302 Open only code blocks.
1303 @item comment
1304 Open only comments.
1305 @item t
1306 Open both code blocks and comments.
1307 @item nil
1308 Open neither code blocks nor comments.
1309 @end table
1310
1311 @item hs-special-modes-alist
1312 A list of elements, each specifying how to initialize Hideshow
1313 variables for one major mode. See the variable's documentation string
1314 for more information.
1315 @end table
1316
1317 @node Symbol Completion
1318 @section Completion for Symbol Names
1319 @cindex completion (symbol names)
1320
1321 In Emacs, completion is something you normally do in the minibuffer
1322 (@pxref{Completion}). But one kind of completion is available in all
1323 buffers: completion for symbol names.
1324
1325 @kindex M-TAB
1326 The character @kbd{M-@key{TAB}} runs a command to complete the
1327 partial symbol before point against the set of meaningful symbol
1328 names. This command inserts at point any additional characters that
1329 it can determine from the partial name.
1330
1331 If your window manager defines @kbd{M-@key{TAB}} to switch windows,
1332 you can type @kbd{@key{ESC} @key{TAB}} or @kbd{C-M-i} instead.
1333 However, most window managers let you customize these shortcuts, and
1334 we recommend that you change any that get in the way of use of Emacs.
1335
1336 If the partial name in the buffer has multiple possible completions
1337 that differ in the very next character, so that it is impossible to
1338 complete even one more character, @kbd{M-@key{TAB}} displays a list of
1339 all possible completions in another window.
1340
1341 @cindex tags-based completion
1342 @cindex Info index completion
1343 @findex complete-symbol
1344 In most programming language major modes, @kbd{M-@key{TAB}} runs the
1345 command @code{complete-symbol}, which provides two kinds of completion.
1346 Normally it does completion based on a tags table (@pxref{Tags}); with a
1347 numeric argument (regardless of the value), it does completion based on
1348 the names listed in the Info file indexes for your language. Thus, to
1349 complete the name of a symbol defined in your own program, use
1350 @kbd{M-@key{TAB}} with no argument; to complete the name of a standard
1351 library function, use @kbd{C-u M-@key{TAB}}. Of course, Info-based
1352 completion works only if there is an Info file for the standard library
1353 functions of your language, and only if it is installed at your site.
1354
1355 @cindex Lisp symbol completion
1356 @cindex completion (Lisp symbols)
1357 @findex lisp-complete-symbol
1358 In Emacs-Lisp mode, the name space for completion normally consists of
1359 nontrivial symbols present in Emacs---those that have function
1360 definitions, values or properties. However, if there is an
1361 open-parenthesis immediately before the beginning of the partial symbol,
1362 only symbols with function definitions are considered as completions.
1363 The command which implements this is @code{lisp-complete-symbol}.
1364
1365 In Text mode and related modes, @kbd{M-@key{TAB}} completes words
1366 based on the spell-checker's dictionary. @xref{Spelling}.
1367
1368 @node Glasses
1369 @section Glasses minor mode
1370 @cindex Glasses mode
1371 @cindex identifiers, making long ones readable
1372 @cindex StudlyCaps, making them readable
1373 @findex glasses-mode
1374
1375 Glasses minor mode makes @samp{unreadableIdentifiersLikeThis}
1376 readable by altering the way they display. It knows two different
1377 ways to do this: by displaying underscores between a lower-case letter
1378 and the following capital letter, and by emboldening the capital
1379 letters. It does not alter the buffer text, only the way they
1380 display, so you can use it even on read-only buffers. You can use the
1381 command @kbd{M-x glasses-mode} to enable or disable the mode in the
1382 current buffer; you can also add @code{glasses-mode} to the mode hook
1383 of the programming language major modes in which you normally want
1384 to use Glasses mode.
1385
1386 @node Misc for Programs
1387 @section Other Features Useful for Editing Programs
1388
1389 A number of Emacs commands that aren't designed specifically for
1390 editing programs are useful for that nonetheless.
1391
1392 The Emacs commands that operate on words, sentences and paragraphs
1393 are useful for editing code. Most symbols names contain words
1394 (@pxref{Words}); sentences can be found in strings and comments
1395 (@pxref{Sentences}). Paragraphs in the strict sense can be found in
1396 program code (in long comments), but the paragraph commands are useful
1397 in other places too, because programming language major modes define
1398 paragraphs to begin and end at blank lines (@pxref{Paragraphs}).
1399 Judicious use of blank lines to make the program clearer will also
1400 provide useful chunks of text for the paragraph commands to work on.
1401 Auto Fill mode, if enabled in a programming language major mode,
1402 indents the new lines which it creates.
1403
1404 The selective display feature is useful for looking at the overall
1405 structure of a function (@pxref{Selective Display}). This feature
1406 hides the lines that are indented more than a specified amount.
1407 Programming modes often support Outline minor mode (@pxref{Outline
1408 Mode}). The Foldout package provides folding-editor features
1409 (@pxref{Foldout}).
1410
1411 The ``automatic typing'' features may be useful for writing programs.
1412 @xref{Top,,Autotyping, autotype, Autotyping}.
1413
1414 @node C Modes
1415 @section C and Related Modes
1416 @cindex C mode
1417 @cindex Java mode
1418 @cindex Pike mode
1419 @cindex IDL mode
1420 @cindex CORBA IDL mode
1421 @cindex Objective C mode
1422 @cindex C++ mode
1423 @cindex AWK mode
1424 @cindex mode, Java
1425 @cindex mode, C
1426 @cindex mode, C++
1427 @cindex mode, Objective C
1428 @cindex mode, CORBA IDL
1429 @cindex mode, Pike
1430 @cindex mode, AWK
1431
1432 This section gives a brief description of the special features
1433 available in C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes.
1434 (These are called ``C mode and related modes.'') @xref{Top, , CC Mode,
1435 ccmode, CC Mode}, for a more extensive description of these modes
1436 and their special features.
1437
1438 @menu
1439 * Motion in C:: Commands to move by C statements, etc.
1440 * Electric C:: Colon and other chars can automatically reindent.
1441 * Hungry Delete:: A more powerful DEL command.
1442 * Other C Commands:: Filling comments, viewing expansion of macros,
1443 and other neat features.
1444 @end menu
1445
1446 @node Motion in C
1447 @subsection C Mode Motion Commands
1448
1449 This section describes commands for moving point, in C mode and
1450 related modes.
1451
1452 @table @code
1453 @item M-x c-beginning-of-defun
1454 @itemx M-x c-end-of-defun
1455 @findex c-beginning-of-defun
1456 @findex c-end-of-defun
1457 Move point to the beginning or end of the current function or
1458 top-level definition. These are found by searching for the least
1459 enclosing braces. (By contrast, @code{beginning-of-defun} and
1460 @code{end-of-defun} search for braces in column zero.) If you are
1461 editing code where the opening brace of a function isn't placed in
1462 column zero, you may wish to bind @code{C-M-a} and @code{C-M-e} to
1463 these commands. @xref{Moving by Defuns}.
1464
1465 @item C-c C-u
1466 @kindex C-c C-u @r{(C mode)}
1467 @findex c-up-conditional
1468 Move point back to the containing preprocessor conditional, leaving the
1469 mark behind. A prefix argument acts as a repeat count. With a negative
1470 argument, move point forward to the end of the containing
1471 preprocessor conditional.
1472
1473 @samp{#elif} is equivalent to @samp{#else} followed by @samp{#if}, so
1474 the function will stop at a @samp{#elif} when going backward, but not
1475 when going forward.
1476
1477 @item C-c C-p
1478 @kindex C-c C-p @r{(C mode)}
1479 @findex c-backward-conditional
1480 Move point back over a preprocessor conditional, leaving the mark
1481 behind. A prefix argument acts as a repeat count. With a negative
1482 argument, move forward.
1483
1484 @item C-c C-n
1485 @kindex C-c C-n @r{(C mode)}
1486 @findex c-forward-conditional
1487 Move point forward across a preprocessor conditional, leaving the mark
1488 behind. A prefix argument acts as a repeat count. With a negative
1489 argument, move backward.
1490
1491 @item M-a
1492 @kindex M-a (C mode)
1493 @findex c-beginning-of-statement
1494 Move point to the beginning of the innermost C statement
1495 (@code{c-beginning-of-statement}). If point is already at the beginning
1496 of a statement, move to the beginning of the preceding statement. With
1497 prefix argument @var{n}, move back @var{n} @minus{} 1 statements.
1498
1499 In comments or in strings which span more than one line, this command
1500 moves by sentences instead of statements.
1501
1502 @item M-e
1503 @kindex M-e (C mode)
1504 @findex c-end-of-statement
1505 Move point to the end of the innermost C statement or sentence; like
1506 @kbd{M-a} except that it moves in the other direction
1507 (@code{c-end-of-statement}).
1508 @end table
1509
1510 @node Electric C
1511 @subsection Electric C Characters
1512
1513 In C mode and related modes, certain printing characters are
1514 @dfn{electric}---in addition to inserting themselves, they also
1515 reindent the current line, and optionally also insert newlines. The
1516 ``electric'' characters are @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#},
1517 @kbd{;}, @kbd{,}, @kbd{<}, @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and
1518 @kbd{)}.
1519
1520 You might find electric indentation inconvenient if you are editing
1521 chaotically indented code. If you are new to CC Mode, you might find
1522 it disconcerting. You can toggle electric action with the command
1523 @kbd{C-c C-l}; when it is enabled, @samp{/l} appears in the mode line
1524 after the mode name:
1525
1526 @table @kbd
1527 @item C-c C-l
1528 @kindex C-c C-l @r{(C mode)}
1529 @findex c-toggle-electric-state
1530 Toggle electric action (@code{c-toggle-electric-state}). With a
1531 prefix argument, this command enables electric action if the argument
1532 is positive, disables it if it is negative.
1533 @end table
1534
1535 Electric characters insert newlines only when, in addition to the
1536 electric state, the @dfn{auto-newline} feature is enabled (indicated
1537 by @samp{/la} in the mode line after the mode name). You can turn
1538 this feature on or off with the command @kbd{C-c C-a}:
1539
1540 @table @kbd
1541 @item C-c C-a
1542 @kindex C-c C-a @r{(C mode)}
1543 @findex c-toggle-auto-newline
1544 Toggle the auto-newline feature (@code{c-toggle-auto-newline}). With a
1545 prefix argument, this command turns the auto-newline feature on if the
1546 argument is positive, and off if it is negative.
1547 @end table
1548
1549 Usually the CC Mode style configures the exact circumstances in
1550 which Emacs inserts auto-newlines. You can also configure this
1551 directly. @xref{Custom Auto-newlines,,, ccmode, The CC Mode Manual}.
1552
1553 @node Hungry Delete
1554 @subsection Hungry Delete Feature in C
1555 @cindex hungry deletion (C Mode)
1556
1557 If you want to delete an entire block of whitespace at point, you
1558 can use @dfn{hungry deletion}. This deletes all the contiguous
1559 whitespace either before point or after point in a single operation.
1560 @dfn{Whitespace} here includes tabs and newlines, but not comments or
1561 preprocessor commands.
1562
1563 @table @kbd
1564 @item C-c C-@key{DEL}
1565 @itemx C-c @key{DEL}
1566 @findex c-hungry-delete-backwards
1567 @kindex C-c C-@key{DEL} (C Mode)
1568 @kindex C-c @key{DEL} (C Mode)
1569 @code{c-hungry-delete-backwards}---Delete the entire block of whitespace
1570 preceding point.
1571
1572 @item C-c C-d
1573 @itemx C-c C-@key{DELETE}
1574 @itemx C-c @key{DELETE}
1575 @findex c-hungry-delete-forward
1576 @kindex C-c C-d (C Mode)
1577 @kindex C-c C-@key{DELETE} (C Mode)
1578 @kindex C-c @key{DELETE} (C Mode)
1579 @code{c-hungry-delete-forward}---Delete the entire block of whitespace
1580 following point.
1581 @end table
1582
1583 As an alternative to the above commands, you can enable @dfn{hungry
1584 delete mode}. When this feature is enabled (indicated by @samp{/h} in
1585 the mode line after the mode name), a single @key{DEL} deletes all
1586 preceding whitespace, not just one space, and a single @kbd{C-c C-d}
1587 (but @emph{not} plain @key{DELETE}) deletes all following whitespace.
1588
1589 @table @kbd
1590 @item M-x c-toggle-hungry-state
1591 @findex c-toggle-hungry-state
1592 Toggle the hungry-delete feature
1593 (@code{c-toggle-hungry-state})@footnote{This command had the binding
1594 @kbd{C-c C-d} in earlier versions of Emacs. @kbd{C-c C-d} is now
1595 bound to @code{c-hungry-delete-forward}.}. With a prefix argument,
1596 this command turns the hungry-delete feature on if the argument is
1597 positive, and off if it is negative.
1598 @end table
1599
1600 @vindex c-hungry-delete-key
1601 The variable @code{c-hungry-delete-key} controls whether the
1602 hungry-delete feature is enabled.
1603
1604 @node Other C Commands
1605 @subsection Other Commands for C Mode
1606
1607 @table @kbd
1608 @item C-c C-w
1609 @itemx M-x c-subword-mode
1610 @findex c-subword-mode
1611 Enable (or disable) @dfn{subword mode}. In subword mode, Emacs's word
1612 commands recognize upper case letters in
1613 @samp{StudlyCapsIdentifiers} as word boundaries. This is indicated by
1614 the flag @samp{/w} on the mode line after the mode name
1615 (e.g. @samp{C/law}). You can even use @kbd{M-x c-subword-mode} in
1616 non-CC Mode buffers.
1617
1618 In the GNU project, we recommend using underscores to separate words
1619 within an identifier in C or C++, rather than using case distinctions.
1620
1621 @item M-x c-context-line-break
1622 @findex c-context-line-break
1623 This command inserts a line break and indents the new line in a manner
1624 appropriate to the context. In normal code, it does the work of
1625 @kbd{C-j} (@code{newline-and-indent}), in a C preprocessor line it
1626 additionally inserts a @samp{\} at the line break, and within comments
1627 it's like @kbd{M-j} (@code{c-indent-new-comment-line}).
1628
1629 @code{c-context-line-break} isn't bound to a key by default, but it
1630 needs a binding to be useful. The following code will bind it to
1631 @kbd{C-j}. We use @code{c-initialization-hook} here to make sure
1632 the keymap is loaded before we try to change it.
1633
1634 @smallexample
1635 (defun my-bind-clb ()
1636 (define-key c-mode-base-map "\C-j" 'c-context-line-break))
1637 (add-hook 'c-initialization-hook 'my-bind-clb)
1638 @end smallexample
1639
1640 @item C-M-h
1641 Put mark at the end of a function definition, and put point at the
1642 beginning (@code{c-mark-function}).
1643
1644 @item M-q
1645 @kindex M-q @r{(C mode)}
1646 @findex c-fill-paragraph
1647 Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}).
1648 If any part of the current line is a comment or within a comment, this
1649 command fills the comment or the paragraph of it that point is in,
1650 preserving the comment indentation and comment delimiters.
1651
1652 @item C-c C-e
1653 @cindex macro expansion in C
1654 @cindex expansion of C macros
1655 @findex c-macro-expand
1656 @kindex C-c C-e @r{(C mode)}
1657 Run the C preprocessor on the text in the region, and show the result,
1658 which includes the expansion of all the macro calls
1659 (@code{c-macro-expand}). The buffer text before the region is also
1660 included in preprocessing, for the sake of macros defined there, but the
1661 output from this part isn't shown.
1662
1663 When you are debugging C code that uses macros, sometimes it is hard to
1664 figure out precisely how the macros expand. With this command, you
1665 don't have to figure it out; you can see the expansions.
1666
1667 @item C-c C-\
1668 @findex c-backslash-region
1669 @kindex C-c C-\ @r{(C mode)}
1670 Insert or align @samp{\} characters at the ends of the lines of the
1671 region (@code{c-backslash-region}). This is useful after writing or
1672 editing a C macro definition.
1673
1674 If a line already ends in @samp{\}, this command adjusts the amount of
1675 whitespace before it. Otherwise, it inserts a new @samp{\}. However,
1676 the last line in the region is treated specially; no @samp{\} is
1677 inserted on that line, and any @samp{\} there is deleted.
1678
1679 @item M-x cpp-highlight-buffer
1680 @cindex preprocessor highlighting
1681 @findex cpp-highlight-buffer
1682 Highlight parts of the text according to its preprocessor conditionals.
1683 This command displays another buffer named @samp{*CPP Edit*}, which
1684 serves as a graphic menu for selecting how to display particular kinds
1685 of conditionals and their contents. After changing various settings,
1686 click on @samp{[A]pply these settings} (or go to that buffer and type
1687 @kbd{a}) to rehighlight the C mode buffer accordingly.
1688
1689 @item C-c C-s
1690 @findex c-show-syntactic-information
1691 @kindex C-c C-s @r{(C mode)}
1692 Display the syntactic information about the current source line
1693 (@code{c-show-syntactic-information}). This information directs how
1694 the line is indented.
1695
1696 @item M-x cwarn-mode
1697 @itemx M-x global-cwarn-mode
1698 @findex cwarn-mode
1699 @findex global-cwarn-mode
1700 @vindex global-cwarn-mode
1701 @cindex CWarn mode
1702 @cindex suspicious constructions in C, C++
1703 CWarn minor mode highlights certain suspicious C and C++ constructions:
1704
1705 @itemize @bullet{}
1706 @item
1707 Assignments inside expressions.
1708 @item
1709 Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while}
1710 (except after a @samp{do @dots{} while} statement);
1711 @item
1712 C++ functions with reference parameters.
1713 @end itemize
1714
1715 @noindent
1716 You can enable the mode for one buffer with the command @kbd{M-x
1717 cwarn-mode}, or for all suitable buffers with the command @kbd{M-x
1718 global-cwarn-mode} or by customizing the variable
1719 @code{global-cwarn-mode}. You must also enable Font Lock mode to make
1720 it work.
1721
1722 @item M-x hide-ifdef-mode
1723 @findex hide-ifdef-mode
1724 @cindex Hide-ifdef mode
1725 Hide-ifdef minor mode hides selected code within @samp{#if} and
1726 @samp{#ifdef} preprocessor blocks. See the documentation string of
1727 @code{hide-ifdef-mode} for more information.
1728
1729 @item M-x ff-find-related-file
1730 @cindex related files
1731 @findex ff-find-related-file
1732 @vindex ff-related-file-alist
1733 Find a file ``related'' in a special way to the file visited by the
1734 current buffer. Typically this will be the header file corresponding
1735 to a C/C++ source file, or vice versa. The variable
1736 @code{ff-related-file-alist} specifies how to compute related file
1737 names.
1738 @end table
1739
1740 @node Asm Mode
1741 @section Asm Mode
1742
1743 @cindex Asm mode
1744 @cindex assembler mode
1745 Asm mode is a major mode for editing files of assembler code. It
1746 defines these commands:
1747
1748 @table @kbd
1749 @item @key{TAB}
1750 @code{tab-to-tab-stop}.
1751 @item C-j
1752 Insert a newline and then indent using @code{tab-to-tab-stop}.
1753 @item :
1754 Insert a colon and then remove the indentation from before the label
1755 preceding colon. Then do @code{tab-to-tab-stop}.
1756 @item ;
1757 Insert or align a comment.
1758 @end table
1759
1760 The variable @code{asm-comment-char} specifies which character
1761 starts comments in assembler syntax.
1762
1763 @ifnottex
1764 @include fortran-xtra.texi
1765 @end ifnottex
1766
1767 @ignore
1768 arch-tag: c7ee7409-40a4-45c7-bfb7-ae7f2c74d0c0
1769 @end ignore