* shell.el (shell-completion-vars): Fix last change.
[emacs.git] / doc / emacs / programs.texi
blobb7f21e8a93c39c4bc3dce058c4f93d112b64f539
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2012
3 @c   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
11   This chapter describes Emacs features for facilitating editing
12 programs.  Some of the things these features can do are:
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
28 @menu
29 * Program Modes::       Major modes for editing programs.
30 * Defuns::              Commands to operate on major top-level parts
31                           of a program.
32 * Program Indent::      Adjusting indentation to show the nesting.
33 * Parentheses::         Commands that operate on parentheses.
34 * Comments::            Inserting, killing, and aligning comments.
35 * Documentation::       Getting documentation of functions you plan to call.
36 * Hideshow::            Displaying blocks selectively.
37 * Symbol Completion::   Completion on symbol names of your program or language.
38 * Glasses::             Making identifiersLikeThis more readable.
39 * Semantic::            Suite of editing tools based on source code parsing.
40 * Misc for Programs::   Other Emacs features useful for editing programs.
41 * C Modes::             Special commands of C, C++, Objective-C, Java,
42                           IDL, Pike and AWK modes.
43 * Asm Mode::            Asm mode and its special features.
44 @ifnottex
45 * Fortran::             Fortran mode and its special features.
46 @end ifnottex
47 @end menu
49 @node Program Modes
50 @section Major Modes for Programming Languages
51 @cindex modes for programming languages
53   Emacs has specialized major modes (@pxref{Major Modes}) for many
54 programming languages.  A programming language mode typically
55 specifies the syntax of expressions, the customary rules for
56 indentation, how to do syntax highlighting for the language, and how
57 to find the beginning or end of a function definition.  It often has
58 features for compiling and debugging programs as well.  The major mode
59 for each language is named after the language; for instance, the major
60 mode for the C programming language is @code{c-mode}.
62 @cindex Perl mode
63 @cindex Icon mode
64 @cindex Makefile mode
65 @cindex Tcl mode
66 @cindex CPerl mode
67 @cindex DSSSL mode
68 @cindex Octave mode
69 @cindex Metafont mode
70 @cindex Modula2 mode
71 @cindex Prolog mode
72 @cindex Python mode
73 @cindex Ruby mode
74 @cindex Simula mode
75 @cindex VHDL mode
76 @cindex M4 mode
77 @cindex Shell-script mode
78 @cindex Delphi mode
79 @cindex PostScript mode
80 @cindex Conf mode
81 @cindex DNS mode
82 @cindex Javascript mode
83   Emacs has programming language modes for Lisp, Scheme, the
84 Scheme-based DSSSL expression language, Ada, ASM, AWK, C, C++, Delphi,
85 Fortran, Icon, IDL (CORBA), IDLWAVE, Java, Javascript, Metafont
86 (@TeX{}'s companion for font creation), Modula2, Objective-C, Octave,
87 Pascal, Perl, Pike, PostScript, Prolog, Python, Ruby, Simula, Tcl, and
88 VHDL.  An alternative mode for Perl is called CPerl mode.  Modes are
89 also available for the scripting languages of the common GNU and Unix
90 shells, VMS DCL, and MS-DOS/MS-Windows @samp{BAT} files, and for
91 makefiles, DNS master files, and various sorts of configuration files.
93   Ideally, Emacs should have a major mode for each programming
94 language that you might want to edit.  If it doesn't have a mode for
95 your favorite language, the mode might be implemented in a package not
96 distributed with Emacs (@pxref{Packages}); or you can contribute one.
98 @kindex DEL @r{(programming modes)}
99 @findex c-electric-backspace
100 @findex backward-delete-char-untabify
101   In most programming languages, indentation should vary from line to
102 line to illustrate the structure of the program.  Therefore, in most
103 programming language modes, typing @key{TAB} updates the indentation
104 of the current line (@pxref{Program Indent}).  Furthermore, @key{DEL}
105 is usually bound to @code{backward-delete-char-untabify}, which
106 deletes backward treating each tab as if it were the equivalent number
107 of spaces, so that you can delete one column of indentation without
108 worrying whether the whitespace consists of spaces or tabs.
110 @cindex mode hook
111 @vindex c-mode-hook
112 @vindex lisp-mode-hook
113 @vindex emacs-lisp-mode-hook
114 @vindex lisp-interaction-mode-hook
115 @vindex scheme-mode-hook
116   Entering a programming language mode runs the custom Lisp functions
117 specified in the hook variable @code{prog-mode-hook}, followed by
118 those specified in the mode's own mode hook (@pxref{Major Modes}).
119 For instance, entering C mode runs the hooks @code{prog-mode-hook} and
120 @code{c-mode-hook}.  @xref{Hooks}, for information about hooks.
122 @ifinfo
123   Separate manuals are available for the modes for Ada (@pxref{Top,,
124 Ada Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba
125 IDL/Pike/AWK (@pxref{Top, , CC Mode, ccmode, CC Mode}), and IDLWAVE
126 (@pxref{Top,, IDLWAVE, idlwave, IDLWAVE User Manual}).
127 @end ifinfo
128 @ifnotinfo
129   The Emacs distribution contains Info manuals for the major modes for
130 Ada, C/C++/Objective C/Java/Corba IDL/Pike/AWK, and IDLWAVE.  For
131 Fortran mode, @pxref{Fortran,,, emacs-xtra, Specialized Emacs Features}.
132 @end ifnotinfo
134 @node Defuns
135 @section Top-Level Definitions, or Defuns
137   In Emacs, a major definition at the top level in the buffer, such as
138 a function, is called a @dfn{defun}.  The name comes from Lisp, but in
139 Emacs we use it for all languages.
141 @menu
142 * Left Margin Paren::   An open-paren or similar opening delimiter
143                           starts a defun if it is at the left margin.
144 * Moving by Defuns::    Commands to move over or mark a major definition.
145 * Imenu::               Making buffer indexes as menus.
146 * Which Function::      Which Function mode shows which function you are in.
147 @end menu
149 @node Left Margin Paren
150 @subsection Left Margin Convention
152 @cindex open-parenthesis in leftmost column
153 @cindex ( in leftmost column
154   Many programming-language modes assume by default that any opening
155 delimiter found at the left margin is the start of a top-level
156 definition, or defun.  Therefore, @strong{don't put an opening
157 delimiter at the left margin unless it should have that significance}.
158 For instance, never put an open-parenthesis at the left margin in a
159 Lisp file unless it is the start of a top-level list.
161   The convention speeds up many Emacs operations, which would
162 otherwise have to scan back to the beginning of the buffer to analyze
163 the syntax of the code.
165   If you don't follow this convention, not only will you have trouble
166 when you explicitly use the commands for motion by defuns; other
167 features that use them will also give you trouble.  This includes the
168 indentation commands (@pxref{Program Indent}) and Font Lock mode
169 (@pxref{Font Lock}).
171   The most likely problem case is when you want an opening delimiter
172 at the start of a line inside a string.  To avoid trouble, put an
173 escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some
174 other Lisp dialects) before the opening delimiter.  This will not
175 affect the contents of the string, but will prevent that opening
176 delimiter from starting a defun.  Here's an example:
178 @example
179   (insert "Foo:
180 \(bar)
182 @end example
184   To help you catch violations of this convention, Font Lock mode
185 highlights confusing opening delimiters (those that ought to be
186 quoted) in bold red.
188 @vindex open-paren-in-column-0-is-defun-start
189   If you need to override this convention, you can do so by setting
190 the variable @code{open-paren-in-column-0-is-defun-start}.
191 If this user option is set to @code{t} (the default), opening
192 parentheses or braces at column zero always start defuns.  When it is
193 @code{nil}, defuns are found by searching for parens or braces at the
194 outermost level.
196   Usually, you should leave this option at its default value of
197 @code{t}.  If your buffer contains parentheses or braces in column
198 zero which don't start defuns, and it is somehow impractical to remove
199 these parentheses or braces, it might be helpful to set the option to
200 @code{nil}.  Be aware that this might make scrolling and display in
201 large buffers quite sluggish.  Furthermore, the parentheses and braces
202 must be correctly matched throughout the buffer for it to work
203 properly.
205 @node Moving by Defuns
206 @subsection Moving by Defuns
207 @cindex defuns
209   These commands move point or set up the region based on top-level
210 major definitions, also called @dfn{defuns}.
212 @table @kbd
213 @item C-M-a
214 Move to beginning of current or preceding defun
215 (@code{beginning-of-defun}).
216 @item C-M-e
217 Move to end of current or following defun (@code{end-of-defun}).
218 @item C-M-h
219 Put region around whole current or following defun (@code{mark-defun}).
220 @end table
222 @cindex move to beginning or end of function
223 @cindex function, move to beginning or end
224 @kindex C-M-a
225 @kindex C-M-e
226 @kindex C-M-h
227 @findex beginning-of-defun
228 @findex end-of-defun
229 @findex mark-defun
230   The commands to move to the beginning and end of the current defun
231 are @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e}
232 (@code{end-of-defun}).  If you repeat one of these commands, or use a
233 positive numeric argument, each repetition moves to the next defun in
234 the direction of motion.
236   @kbd{C-M-a} with a negative argument @minus{}@var{n} moves forward
237 @var{n} times to the next beginning of a defun.  This is not exactly
238 the same place that @kbd{C-M-e} with argument @var{n} would move to;
239 the end of this defun is not usually exactly the same place as the
240 beginning of the following defun.  (Whitespace, comments, and perhaps
241 declarations can separate them.)  Likewise, @kbd{C-M-e} with a
242 negative argument moves back to an end of a defun, which is not quite
243 the same as @kbd{C-M-a} with a positive argument.
245 @kindex C-M-h @r{(C mode)}
246 @findex c-mark-function
247   To operate on the current defun, use @kbd{C-M-h}
248 (@code{mark-defun}), which sets the mark at the end of the current
249 defun and puts point at its beginning.  @xref{Marking Objects}.  This
250 is the easiest way to get ready to kill the defun in order to move it
251 to a different place in the file.  If you use the command while point
252 is between defuns, it uses the following defun.  If you use the
253 command while the mark is already active, it sets the mark but does
254 not move point; furthermore, each successive use of @kbd{C-M-h}
255 extends the end of the region to include one more defun.
257   In C mode, @kbd{C-M-h} runs the function @code{c-mark-function},
258 which is almost the same as @code{mark-defun}; the difference is that
259 it backs up over the argument declarations, function name and returned
260 data type so that the entire C function is inside the region.  This is
261 an example of how major modes adjust the standard key bindings so that
262 they do their standard jobs in a way better fitting a particular
263 language.  Other major modes may replace any or all of these key
264 bindings for that purpose.
266 @node Imenu
267 @subsection Imenu
268 @cindex index of buffer definitions
269 @cindex buffer definitions index
271   The Imenu facility offers a way to find the major definitions in
272 a file by name.  It is also useful in text formatter major modes,
273 where it treats each chapter, section, etc., as a definition.
274 (@xref{Tags}, for a more powerful feature that handles multiple files
275 together.)
277 @findex imenu
278   If you type @kbd{M-x imenu}, it reads the name of a definition using
279 the minibuffer, then moves point to that definition.  You can use
280 completion to specify the name; the command always displays the whole
281 list of valid names.
283 @findex imenu-add-menubar-index
284   Alternatively, you can bind the command @code{imenu} to a mouse
285 click.  Then it displays mouse menus for you to select a definition
286 name.  You can also add the buffer's index to the menu bar by calling
287 @code{imenu-add-menubar-index}.  If you want to have this menu bar
288 item available for all buffers in a certain major mode, you can do
289 this by adding @code{imenu-add-menubar-index} to its mode hook.  But
290 if you have done that, you will have to wait a little while each time
291 you visit a file in that mode, while Emacs finds all the definitions
292 in that buffer.
294 @vindex imenu-auto-rescan
295   When you change the contents of a buffer, if you add or delete
296 definitions, you can update the buffer's index based on the
297 new contents by invoking the @samp{*Rescan*} item in the menu.
298 Rescanning happens automatically if you set @code{imenu-auto-rescan} to
299 a non-@code{nil} value.  There is no need to rescan because of small
300 changes in the text.
302 @vindex imenu-sort-function
303   You can customize the way the menus are sorted by setting the
304 variable @code{imenu-sort-function}.  By default, names are ordered as
305 they occur in the buffer; if you want alphabetic sorting, use the
306 symbol @code{imenu--sort-by-name} as the value.  You can also
307 define your own comparison function by writing Lisp code.
309   Imenu provides the information to guide Which Function mode
310 @ifnottex
311 (@pxref{Which Function}).
312 @end ifnottex
313 @iftex
314 (see below).
315 @end iftex
316 The Speedbar can also use it (@pxref{Speedbar}).
318 @node Which Function
319 @subsection Which Function Mode
320 @cindex current function name in mode line
322   Which Function mode is a global minor mode (@pxref{Minor Modes})
323 which displays the current function name in the mode line, updating it
324 as you move around in a buffer.
326 @findex which-function-mode
327 @vindex which-func-modes
328   To either enable or disable Which Function mode, use the command
329 @kbd{M-x which-function-mode}.  Although Which Function mode is a
330 global minor mode, it takes effect only in certain major modes: those
331 listed in the variable @code{which-func-modes}.  If the value of
332 @code{which-func-modes} is @code{t} rather than a list of modes, then
333 Which Function mode applies to all major modes that know how to
334 support it---in other words, all the major modes that support Imenu.
336 @node Program Indent
337 @section Indentation for Programs
338 @cindex indentation for programs
340   The best way to keep a program properly indented is to use Emacs to
341 reindent it as you change it.  Emacs has commands to indent either a
342 single line, a specified number of lines, or all of the lines inside a
343 single parenthetical grouping.
345   @xref{Indentation}, for general information about indentation.  This
346 section describes indentation features specific to programming
347 language modes.
349 @menu
350 * Basic Indent::        Indenting a single line.
351 * Multi-line Indent::   Commands to reindent many lines at once.
352 * Lisp Indent::         Specifying how each Lisp function should be indented.
353 * C Indent::            Extra features for indenting C and related modes.
354 * Custom C Indent::     Controlling indentation style for C and related modes.
355 @end menu
357 @cindex pretty-printer
358   Emacs also provides a Lisp pretty-printer in the @code{pp} package,
359 which reformats Lisp objects with nice-looking indentation.
361 @node Basic Indent
362 @subsection Basic Program Indentation Commands
364 @table @kbd
365 @item @key{TAB}
366 Adjust indentation of current line (@code{indent-for-tab-command}).
367 @item C-j
368 Insert a newline, then adjust indentation of following line
369 (@code{newline-and-indent}).
370 @end table
372 @kindex TAB @r{(programming modes)}
373 @findex c-indent-command
374 @findex indent-line-function
375 @findex indent-for-tab-command
376   The basic indentation command is @key{TAB}
377 (@code{indent-for-tab-command}), which was documented in
378 @ref{Indentation}.  In programming language modes, @key{TAB} indents
379 the current line, based on the indentation and syntactic content of
380 the preceding lines; if the region is active, @key{TAB} indents each
381 line within the region, not just the current line.
383 @kindex C-j @r{(indenting source code)}
384 @findex newline-and-indent
385   The command @kbd{C-j} (@code{newline-and-indent}), which was
386 documented in @ref{Indentation Commands}, does the same as @key{RET}
387 followed by @key{TAB}: it inserts a new line, then adjusts the line's
388 indentation.
390   When indenting a line that starts within a parenthetical grouping,
391 Emacs usually places the start of the line under the preceding line
392 within the group, or under the text after the parenthesis.  If you
393 manually give one of these lines a nonstandard indentation (e.g.@: for
394 aesthetic purposes), the lines below will follow it.
396   The indentation commands for most programming language modes assume
397 that a open-parenthesis, open-brace or other opening delimiter at the
398 left margin is the start of a function.  If the code you are editing
399 violates this assumption---even if the delimiters occur in strings or
400 comments---you must set @code{open-paren-in-column-0-is-defun-start}
401 to @code{nil} for indentation to work properly.  @xref{Left Margin
402 Paren}.
404 @node Multi-line Indent
405 @subsection Indenting Several Lines
407   Sometimes, you may want to reindent several lines of code at a time.
408 One way to do this is to use the mark; when the mark is active and the
409 region is non-empty, @key{TAB} indents every line in the region.
410 Alternatively, the command @kbd{C-M-\} (@code{indent-region}) indents
411 every line in the region, whether or not the mark is active
412 (@pxref{Indentation Commands}).
414   In addition, Emacs provides the following commands for indenting
415 large chunks of code:
417 @table @kbd
418 @item C-M-q
419 Reindent all the lines within one parenthetical grouping.
420 @item C-u @key{TAB}
421 Shift an entire parenthetical grouping rigidly sideways so that its
422 first line is properly indented.
423 @item M-x indent-code-rigidly
424 Shift all the lines in the region rigidly sideways, but do not alter
425 lines that start inside comments and strings.
426 @end table
428 @kindex C-M-q
429 @findex indent-pp-sexp
430   To reindent the contents of a single parenthetical grouping,
431 position point before the beginning of the grouping and type
432 @kbd{C-M-q}.  This changes the relative indentation within the
433 grouping, without affecting its overall indentation (i.e.@: the
434 indentation of the line where the grouping starts).  The function that
435 @kbd{C-M-q} runs depends on the major mode; it is
436 @code{indent-pp-sexp} in Lisp mode, @code{c-indent-exp} in C mode,
437 etc.  To correct the overall indentation as well, type @key{TAB}
438 first.
440 @kindex C-u TAB
441   If you like the relative indentation within a grouping but not the
442 indentation of its first line, move point to that first line and type
443 @kbd{C-u @key{TAB}}.  In Lisp, C, and some other major modes,
444 @key{TAB} with a numeric argument reindents the current line as usual,
445 then reindents by the same amount all the lines in the parenthetical
446 grouping starting on the current line.  It is clever, though, and does
447 not alter lines that start inside strings.  Neither does it alter C
448 preprocessor lines when in C mode, but it does reindent any
449 continuation lines that may be attached to them.
451 @findex indent-code-rigidly
452   The command @kbd{M-x indent-code-rigidly} rigidly shifts all the
453 lines in the region sideways, like @code{indent-rigidly} does
454 (@pxref{Indentation Commands}).  It doesn't alter the indentation of
455 lines that start inside a string, unless the region also starts inside
456 that string.  The prefix arg specifies the number of columns to
457 indent.
459 @node Lisp Indent
460 @subsection Customizing Lisp Indentation
461 @cindex customizing Lisp indentation
463   The indentation pattern for a Lisp expression can depend on the function
464 called by the expression.  For each Lisp function, you can choose among
465 several predefined patterns of indentation, or define an arbitrary one with
466 a Lisp program.
468   The standard pattern of indentation is as follows: the second line of the
469 expression is indented under the first argument, if that is on the same
470 line as the beginning of the expression; otherwise, the second line is
471 indented underneath the function name.  Each following line is indented
472 under the previous line whose nesting depth is the same.
474 @vindex lisp-indent-offset
475   If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides
476 the usual indentation pattern for the second line of an expression, so that
477 such lines are always indented @code{lisp-indent-offset} more columns than
478 the containing list.
480 @vindex lisp-body-indent
481   Certain functions override the standard pattern.  Functions whose
482 names start with @code{def} treat the second lines as the start of
483 a @dfn{body}, by indenting the second line @code{lisp-body-indent}
484 additional columns beyond the open-parenthesis that starts the
485 expression.
487 @cindex @code{lisp-indent-function} property
488   You can override the standard pattern in various ways for individual
489 functions, according to the @code{lisp-indent-function} property of
490 the function name.  This is normally done for macro definitions, using
491 the @code{declare} construct.  @xref{Defining Macros,,, elisp, the
492 Emacs Lisp Reference Manual}.
494 @node C Indent
495 @subsection Commands for C Indentation
497   Here are special features for indentation in C mode and related modes:
499 @table @code
500 @item C-c C-q
501 @kindex C-c C-q @r{(C mode)}
502 @findex c-indent-defun
503 Reindent the current top-level function definition or aggregate type
504 declaration (@code{c-indent-defun}).
506 @item C-M-q
507 @kindex C-M-q @r{(C mode)}
508 @findex c-indent-exp
509 Reindent each line in the balanced expression that follows point
510 (@code{c-indent-exp}).  A prefix argument inhibits warning messages
511 about invalid syntax.
513 @item @key{TAB}
514 @findex c-indent-command
515 Reindent the current line, and/or in some cases insert a tab character
516 (@code{c-indent-command}).
518 @vindex c-tab-always-indent
519 If @code{c-tab-always-indent} is @code{t}, this command always reindents
520 the current line and does nothing else.  This is the default.
522 If that variable is @code{nil}, this command reindents the current line
523 only if point is at the left margin or in the line's indentation;
524 otherwise, it inserts a tab (or the equivalent number of spaces,
525 if @code{indent-tabs-mode} is @code{nil}).
527 Any other value (not @code{nil} or @code{t}) means always reindent the
528 line, and also insert a tab if within a comment or a string.
529 @end table
531   To reindent the whole current buffer, type @kbd{C-x h C-M-\}.  This
532 first selects the whole buffer as the region, then reindents that
533 region.
535   To reindent the current block, use @kbd{C-M-u C-M-q}.  This moves
536 to the front of the block and then reindents it all.
538 @node Custom C Indent
539 @subsection Customizing C Indentation
540 @cindex style (for indentation)
542   C mode and related modes use a flexible mechanism for customizing
543 indentation.  C mode indents a source line in two steps: first it
544 classifies the line syntactically according to its contents and
545 context; second, it determines the indentation offset associated by
546 your selected @dfn{style} with the syntactic construct and adds this
547 onto the indentation of the @dfn{anchor statement}.
549 @table @kbd
550 @item C-c . @key{RET} @var{style} @key{RET}
551 Select a predefined style @var{style} (@code{c-set-style}).
552 @end table
554   A @dfn{style} is a named collection of customizations that can be
555 used in C mode and the related modes.  @ref{Styles,,, ccmode, The CC
556 Mode Manual}, for a complete description.  Emacs comes with several
557 predefined styles, including @code{gnu}, @code{k&r}, @code{bsd},
558 @code{stroustrup}, @code{linux}, @code{python}, @code{java},
559 @code{whitesmith}, @code{ellemtel}, and @code{awk}.  Some of these
560 styles are primarily intended for one language, but any of them can be
561 used with any of the languages supported by these modes.  To find out
562 what a style looks like, select it and reindent some code, e.g., by
563 typing @key{C-M-q} at the start of a function definition.
565 @kindex C-c . @r{(C mode)}
566 @findex c-set-style
567   To choose a style for the current buffer, use the command @w{@kbd{C-c
568 .}}.  Specify a style name as an argument (case is not significant).
569 This command affects the current buffer only, and it affects only
570 future invocations of the indentation commands; it does not reindent
571 the code already in the buffer.  To reindent the whole buffer in the
572 new style, you can type @kbd{C-x h C-M-\}.
574 @vindex c-default-style
575   You can also set the variable @code{c-default-style} to specify the
576 default style for various major modes.  Its value should be either the
577 style's name (a string) or an alist, in which each element specifies
578 one major mode and which indentation style to use for it.  For
579 example,
581 @example
582 (setq c-default-style
583       '((java-mode . "java")
584         (awk-mode . "awk")
585         (other . "gnu")))
586 @end example
588 @noindent
589 specifies explicit choices for Java and AWK modes, and the default
590 @samp{gnu} style for the other C-like modes.  (These settings are
591 actually the defaults.)  This variable takes effect when you select
592 one of the C-like major modes; thus, if you specify a new default
593 style for Java mode, you can make it take effect in an existing Java
594 mode buffer by typing @kbd{M-x java-mode} there.
596   The @code{gnu} style specifies the formatting recommended by the GNU
597 Project for C; it is the default, so as to encourage use of our
598 recommended style.
600   @xref{Indentation Engine Basics,,, ccmode, the CC Mode Manual}, and
601 @ref{Customizing Indentation,,, ccmode, the CC Mode Manual}, for more
602 information on customizing indentation for C and related modes,
603 including how to override parts of an existing style and how to define
604 your own styles.
606 @findex c-guess
607 @findex c-guess-install
608   As an alternative to specifying a style, you can tell Emacs to guess
609 a style by typing @kbd{M-x c-guess} in a sample code buffer.  You can
610 then apply the guessed style to other buffers with @kbd{M-x
611 c-guess-install}.  @xref{Guessing the Style,,, ccmode, the CC Mode
612 Manual}, for details.
614 @node Parentheses
615 @section Commands for Editing with Parentheses
617 @findex check-parens
618 @cindex unbalanced parentheses and quotes
619   This section describes the commands and features that take advantage
620 of the parenthesis structure in a program, or help you keep it
621 balanced.
623   When talking about these facilities, the term ``parenthesis'' also
624 includes braces, brackets, or whatever delimiters are defined to match
625 in pairs.  The major mode controls which delimiters are significant,
626 through the syntax table (@pxref{Syntax Tables,, Syntax Tables, elisp,
627 The Emacs Lisp Reference Manual}).  In Lisp, only parentheses count;
628 in C, these commands apply to braces and brackets too.
630   You can use @kbd{M-x check-parens} to find any unbalanced
631 parentheses and unbalanced string quotes in the buffer.
633 @menu
634 * Expressions::         Expressions with balanced parentheses.
635 * Moving by Parens::    Commands for moving up, down and across
636                           in the structure of parentheses.
637 * Matching::            Insertion of a close-delimiter flashes matching open.
638 @end menu
640 @node Expressions
641 @subsection Expressions with Balanced Parentheses
643 @cindex sexp
644 @cindex expression
645 @cindex balanced expression
646   Each programming language mode has its own definition of a
647 @dfn{balanced expression}.  Balanced expressions typically include
648 individual symbols, numbers, and string constants, as well as pieces
649 of code enclosed in a matching pair of delimiters.  The following
650 commands deal with balanced expressions (in Emacs, such expressions
651 are referred to internally as @dfn{sexps}@footnote{The word ``sexp''
652 is used to refer to an expression in Lisp.}).
654 @table @kbd
655 @item C-M-f
656 Move forward over a balanced expression (@code{forward-sexp}).
657 @item C-M-b
658 Move backward over a balanced expression (@code{backward-sexp}).
659 @item C-M-k
660 Kill balanced expression forward (@code{kill-sexp}).
661 @item C-M-t
662 Transpose expressions (@code{transpose-sexps}).
663 @item C-M-@@
664 @itemx C-M-@key{SPC}
665 Put mark after following expression (@code{mark-sexp}).
666 @end table
668 @kindex C-M-f
669 @kindex C-M-b
670 @findex forward-sexp
671 @findex backward-sexp
672   To move forward over a balanced expression, use @kbd{C-M-f}
673 (@code{forward-sexp}).  If the first significant character after point
674 is an opening delimiter (e.g.@: @samp{(}, @samp{[} or @samp{@{} in C),
675 this command moves past the matching closing delimiter.  If the
676 character begins a symbol, string, or number, the command moves over
677 that.
679   The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a
680 balanced expression---like @kbd{C-M-f}, but in the reverse direction.
681 If the expression is preceded by any prefix characters (single-quote,
682 backquote and comma, in Lisp), the command moves back over them as
683 well.
685   @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation
686 the specified number of times; with a negative argument means to move
687 in the opposite direction.  In most modes, these two commands move
688 across comments as if they were whitespace.  Note that their keys,
689 @kbd{C-M-f} and @kbd{C-M-b}, are analogous to @kbd{C-f} and @kbd{C-b},
690 which move by characters (@pxref{Moving Point}), and @kbd{M-f} and
691 @kbd{M-b}, which move by words (@pxref{Words}).
693 @cindex killing expressions
694 @kindex C-M-k
695 @findex kill-sexp
696   To kill a whole balanced expression, type @kbd{C-M-k}
697 (@code{kill-sexp}).  This kills the text that @kbd{C-M-f} would move
698 over.
700 @cindex transposition of expressions
701 @kindex C-M-t
702 @findex transpose-sexps
703   @kbd{C-M-t} (@code{transpose-sexps}) switches the positions of the
704 previous balanced expression and the next one.  It is analogous to the
705 @kbd{C-t} command, which transposes characters (@pxref{Transpose}).
706 An argument to @kbd{C-M-t} serves as a repeat count, moving the
707 previous expression over that many following ones.  A negative
708 argument moves the previous balanced expression backwards across those
709 before it.  An argument of zero, rather than doing nothing, transposes
710 the balanced expressions ending at or after point and the mark.
712 @kindex C-M-@@
713 @kindex C-M-@key{SPC}
714 @findex mark-sexp
715   To operate on balanced expressions with a command which acts on the
716 region, type @kbd{C-M-@key{SPC}} (@code{mark-sexp}).  This sets the
717 mark where @kbd{C-M-f} would move to.  While the mark is active, each
718 successive call to this command extends the region by shifting the
719 mark by one expression.  Positive or negative numeric arguments move
720 the mark forward or backward by the specified number of expressions.
721 The alias @kbd{C-M-@@} is equivalent to @kbd{C-M-@key{SPC}}.
722 @xref{Marking Objects}, for more information about this and related
723 commands.
725   In languages that use infix operators, such as C, it is not possible
726 to recognize all balanced expressions because there can be multiple
727 possibilities at a given position.  For example, C mode does not treat
728 @samp{foo + bar} as a single expression, even though it @emph{is} one
729 C expression; instead, it recognizes @samp{foo} as one expression and
730 @samp{bar} as another, with the @samp{+} as punctuation between them.
731 However, C mode recognizes @samp{(foo + bar)} as a single expression,
732 because of the parentheses.
734 @node Moving by Parens
735 @subsection Moving in the Parenthesis Structure
737 @cindex parenthetical groupings
738 @cindex parentheses, moving across
739 @cindex matching parenthesis and braces, moving to
740 @cindex braces, moving across
741 @cindex list commands
743   The following commands move over groupings delimited by parentheses
744 (or whatever else serves as delimiters in the language you are working
745 with).  They ignore strings and comments, including any parentheses
746 within them, and also ignore parentheses that are ``quoted'' with an
747 escape character.  These commands are mainly intended for editing
748 programs, but can be useful for editing any text containing
749 parentheses.  They are referred to internally as ``list'' commands
750 because in Lisp these groupings are lists.
752   These commands assume that the starting point is not inside a string
753 or a comment.  If you invoke them from inside a string or comment, the
754 results are unreliable.
756 @table @kbd
757 @item C-M-n
758 Move forward over a parenthetical group (@code{forward-list}).
759 @item C-M-p
760 Move backward over a parenthetical group (@code{backward-list}).
761 @item C-M-u
762 Move up in parenthesis structure (@code{backward-up-list}).
763 @item C-M-d
764 Move down in parenthesis structure (@code{down-list}).
765 @end table
767 @kindex C-M-n
768 @kindex C-M-p
769 @findex forward-list
770 @findex backward-list
771   The ``list'' commands @kbd{C-M-n} (@code{forward-list}) and
772 @kbd{C-M-p} (@code{backward-list}) move forward or backward over one
773 (or @var{n}) parenthetical groupings.
775 @kindex C-M-u
776 @findex backward-up-list
777   @kbd{C-M-n} and @kbd{C-M-p} try to stay at the same level in the
778 parenthesis structure.  To move @emph{up} one (or @var{n}) levels, use
779 @kbd{C-M-u} (@code{backward-up-list}).  @kbd{C-M-u} moves backward up
780 past one unmatched opening delimiter.  A positive argument serves as a
781 repeat count; a negative argument reverses the direction of motion, so
782 that the command moves forward and up one or more levels.
784 @kindex C-M-d
785 @findex down-list
786   To move @emph{down} in the parenthesis structure, use @kbd{C-M-d}
787 (@code{down-list}).  In Lisp mode, where @samp{(} is the only opening
788 delimiter, this is nearly the same as searching for a @samp{(}.  An
789 argument specifies the number of levels to go down.
791 @node Matching
792 @subsection Matching Parentheses
793 @cindex matching parentheses
794 @cindex parentheses, displaying matches
796   Emacs has a number of @dfn{parenthesis matching} features, which
797 make it easy to see how and whether parentheses (or other delimiters)
798 match up.
800   Whenever you type a self-inserting character that is a closing
801 delimiter, the cursor moves momentarily to the location of the
802 matching opening delimiter, provided that is on the screen.  If it is
803 not on the screen, Emacs displays some of the text near it in the echo
804 area.  Either way, you can tell which grouping you are closing off.
805 If the opening delimiter and closing delimiter are mismatched---such
806 as in @samp{[x)}---a warning message is displayed in the echo area.
808 @vindex blink-matching-paren
809 @vindex blink-matching-paren-distance
810 @vindex blink-matching-delay
811   Three variables control the display of matching parentheses:
813 @itemize @bullet
814 @item
815 @code{blink-matching-paren} turns the feature on or off: @code{nil}
816 disables it, but the default is @code{t} to enable it.
818 @item
819 @code{blink-matching-delay} says how many seconds to leave the cursor
820 on the matching opening delimiter, before bringing it back to the real
821 location of point.  This may be an integer or floating-point number;
822 the default is 1.
824 @item
825 @code{blink-matching-paren-distance} specifies how many characters
826 back to search to find the matching opening delimiter.  If the match
827 is not found in that distance, Emacs stops scanning and nothing is
828 displayed.  The default is 102400.
829 @end itemize
831 @cindex Show Paren mode
832 @cindex highlighting matching parentheses
833 @findex show-paren-mode
834   Show Paren mode, a global minor mode, provides a more powerful kind
835 of automatic matching.  Whenever point is before an opening delimiter
836 or after a closing delimiter, both that delimiter and its opposite
837 delimiter are highlighted.  To toggle Show Paren mode, type @kbd{M-x
838 show-paren-mode}.
840 @cindex Electric Pair mode
841 @cindex inserting matching parentheses
842 @findex electric-pair-mode
843   Electric Pair mode, a global minor mode, provides a way to easily
844 insert matching delimiters.  Whenever you insert an opening delimiter,
845 the matching closing delimiter is automatically inserted as well,
846 leaving point between the two.  To toggle Electric Pair mode, type
847 @kbd{M-x electric-pair-mode}.
849 @node Comments
850 @section Manipulating Comments
851 @cindex comments
853   Because comments are such an important part of programming, Emacs
854 provides special commands for editing and inserting comments.  It can
855 also do spell checking on comments with Flyspell Prog mode
856 (@pxref{Spelling}).
858   Some major modes have special rules for indenting different kinds of
859 comments.  For example, in Lisp code, comments starting with two
860 semicolons are indented as if they were lines of code, while those
861 starting with three semicolons are supposed to be aligned to the left
862 margin and are often used for sectioning purposes.  Emacs understand
863 these conventions; for instance, typing @key{TAB} on a comment line
864 will indent the comment to the appropriate position.
866 @example
867 ;; This function is just an example.
868 ;;; Here either two or three semicolons are appropriate.
869 (defun foo (x)
870 ;;;  And now, the first part of the function:
871   ;; The following line adds one.
872   (1+ x))           ; This line adds one.
873 @end example
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
881 @node Comment Commands
882 @subsection Comment Commands
883 @cindex indentation for comments
884 @cindex alignment for comments
886   The following commands operate on comments:
888 @table @asis
889 @item @kbd{M-;}
890 Insert or realign comment on current line; if the region is active,
891 comment or uncomment the region instead (@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 comment delimiters to all the lines in the region.
903 @end table
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.
913   When a region is active (@pxref{Mark}), @kbd{M-;} either adds
914 comment delimiters to the region, or removes them.  If every line in
915 the region is already a comment, it ``uncomments'' each of those lines
916 by removing their comment delimiters.  Otherwise, it adds comment
917 delimiters to enclose the text in the region.
919   If you supply a prefix argument to @kbd{M-;} when a region is
920 active, that specifies the number of comment delimiters to add or
921 delete.  A positive argument @var{n} adds @var{n} delimiters, while a
922 negative argument @var{-n} removes @var{n} delimiters.
924   If the region is not active, and there is no existing comment on the
925 current line, @kbd{M-;} adds a new comment to the current line.  If
926 the line is blank (i.e.@: empty or containing only whitespace
927 characters), the comment is indented to the same position where
928 @key{TAB} would indent to (@pxref{Basic Indent}).  If the line is
929 non-blank, the comment is placed after the last non-whitespace
930 character on the line; normally, Emacs tries putting it at the column
931 specified by the variable @code{comment-column} (@pxref{Options for
932 Comments}), but if the line already extends past that column, it puts
933 the comment at some suitable position, usually separated from the
934 non-comment text by at least one space.  In each case, Emacs places
935 point after the comment's starting delimiter, so that you can start
936 typing the comment text right away.
938   You can also use @kbd{M-;} to align an existing comment.  If a line
939 already contains the comment-start string, @kbd{M-;} realigns it to
940 the conventional alignment and moves point after the comment's
941 starting delimiter.  As an exception, comments starting in column 0
942 are not moved.  Even when an existing comment is properly aligned,
943 @kbd{M-;} is still useful for moving directly to the start of the
944 comment text.
946 @findex comment-kill
947 @kindex C-u M-;
948   @kbd{C-u M-;} (@code{comment-dwim} with a prefix argument) kills any
949 comment on the current line, along with the whitespace before it.
950 Since the comment is saved to the kill ring, you can reinsert it on
951 another line by moving to the end of that line, doing @kbd{C-y}, and
952 then @kbd{M-;} to realign the comment.  You can achieve the same
953 effect as @kbd{C-u M-;} by typing @kbd{M-x comment-kill}
954 (@code{comment-dwim} actually calls @code{comment-kill} as a
955 subroutine when it is given a prefix argument).
957 @kindex C-c C-c (C mode)
958 @findex comment-region
959 @findex uncomment-region
960   The command @kbd{M-x comment-region} is equivalent to calling
961 @kbd{M-;} on an active region, except that it always acts on the
962 region, even if the mark is inactive.  In C mode and related modes,
963 this command is bound to @kbd{C-c C-c}.  The command @kbd{M-x
964 uncomment-region} uncomments each line in the region; a numeric prefix
965 argument specifies the number of comment delimiters to remove
966 (negative arguments specify the number of comment to delimiters to
967 add).
969   For C-like modes, you can configure the exact effect of @kbd{M-;} by
970 setting the variables @code{c-indent-comment-alist} and
971 @code{c-indent-comments-syntactically-p}.  For example, on a line
972 ending in a closing brace, @kbd{M-;} puts the comment one space after
973 the brace rather than at @code{comment-column}.  For full details see
974 @ref{Comment Commands,,, ccmode, The CC Mode Manual}.
976 @node Multi-Line Comments
977 @subsection Multiple Lines of Comments
979 @kindex C-M-j
980 @kindex M-j
981 @cindex blank lines in programs
982 @findex comment-indent-new-line
983 @vindex comment-multi-line
984   If you are typing a comment and wish to continue it to another line,
985 type @kbd{M-j} or @kbd{C-M-j} (@code{comment-indent-new-line}).  This
986 breaks the current line, and inserts the necessary comment delimiters
987 and indentation to continue the comment.
989   For languages with closing comment delimiters (e.g.@: @samp{*/} in
990 C), the exact behavior of @kbd{M-j} depends on the value of the
991 variable @code{comment-multi-line}.  If the value is @code{nil}, the
992 command closes the comment on the old line and starts a new comment on
993 the new line.  Otherwise, it opens a new line within the current
994 comment delimiters.
996   When Auto Fill mode is on, going past the fill column while typing a
997 comment also continues the comment, in the same way as an explicit
998 invocation of @kbd{M-j}.
1000   To turn existing lines into comment lines, use @kbd{M-;} with the
1001 region active, or use @kbd{M-x comment-region}
1002 @ifinfo
1003 (@pxref{Comment Commands}).
1004 @end ifinfo
1005 @ifnotinfo
1006 as described in the preceding section.
1007 @end ifnotinfo
1009   You can configure C Mode such that when you type a @samp{/} at the
1010 start of a line in a multi-line block comment, this closes the
1011 comment.  Enable the @code{comment-close-slash} clean-up for this.
1012 @xref{Clean-ups,,, ccmode, The CC Mode Manual}.
1014 @node Options for Comments
1015 @subsection Options Controlling Comments
1017 @vindex comment-column
1018 @kindex C-x ;
1019 @findex comment-set-column
1020   As mentioned in @ref{Comment Commands}, when the @kbd{M-j} command
1021 adds a comment to a line, it tries to place the comment at the column
1022 specified by the buffer-local variable @code{comment-column}.  You can
1023 set either the local value or the default value of this buffer-local
1024 variable in the usual way (@pxref{Locals}).  Alternatively, you can
1025 type @kbd{C-x ;} (@code{comment-set-column}) to set the value of
1026 @code{comment-column} in the current buffer to the column where point
1027 is currently located.  @kbd{C-u C-x ;} sets the comment column to
1028 match the last comment before point in the buffer, and then does a
1029 @kbd{M-;} to align the current line's comment under the previous one.
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{"\\(//+\\|/\\*+\\)\\s *"}}, which matches extra stars and
1039 spaces after the @samp{/*} itself, and accepts C++ style comments
1040 also.  (Note that @samp{\\} is needed in Lisp syntax to include a
1041 @samp{\} in the string, which is needed to deny the first star its
1042 special meaning in regexp syntax.  @xref{Regexp Backslash}.)
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} as an opening comment delimiter.  It also inserts
1048 the value of @code{comment-end} after point, as a closing comment
1049 delimiter.  For example, in Lisp mode, @code{comment-start} is
1050 @samp{";"} and @code{comment-end} is @code{""} (the empty string).  In
1051 C mode, @code{comment-start} is @code{"/* "} and @code{comment-end} is
1052 @code{" */"}.
1054 @vindex comment-padding
1055   The variable @code{comment-padding} specifies a string that the
1056 commenting commands should insert between the comment delimiter(s) and
1057 the comment text.  The default, @samp{" "}, specifies a single space.
1058 Alternatively, the value can be a number, which specifies that number
1059 of spaces, or @code{nil}, which means no spaces at all.
1061   The variable @code{comment-multi-line} controls how @kbd{M-j} and
1062 Auto Fill mode continue comments over multiple lines.
1063 @xref{Multi-Line Comments}.
1065 @vindex comment-indent-function
1066   The variable @code{comment-indent-function} should contain a function
1067 that will be called to compute the alignment for a newly inserted
1068 comment or for aligning an existing comment.  It is set differently by
1069 various major modes.  The function is called with no arguments, but with
1070 point at the beginning of the comment, or at the end of a line if a new
1071 comment is to be inserted.  It should return the column in which the
1072 comment ought to start.  For example, in Lisp mode, the indent hook
1073 function bases its decision on how many semicolons begin an existing
1074 comment, and on the code in the preceding lines.
1076 @node Documentation
1077 @section Documentation Lookup
1079   Emacs provides several features you can use to look up the
1080 documentation of functions, variables and commands that you plan to
1081 use in your program.
1083 @menu
1084 * Info Lookup::         Looking up library functions and commands in Info files.
1085 * Man Page::            Looking up man pages of library functions and commands.
1086 * Lisp Doc::            Looking up Emacs Lisp functions, etc.
1087 @end menu
1089 @node Info Lookup
1090 @subsection Info Documentation Lookup
1092 @findex info-lookup-symbol
1093 @findex info-lookup-file
1094 @kindex C-h S
1095   For major modes that apply to languages which have documentation in
1096 Info, you can use @kbd{C-h S} (@code{info-lookup-symbol}) to view the
1097 Info documentation for a symbol used in the program.  You specify the
1098 symbol with the minibuffer; the default is the symbol appearing in the
1099 buffer at point.  For example, in C mode this looks for the symbol in
1100 the C Library Manual.  The command only works if the appropriate
1101 manual's Info files are installed.
1103   The major mode determines where to look for documentation for the
1104 symbol---which Info files to look in, and which indices to search.
1105 You can also use @kbd{M-x info-lookup-file} to look for documentation
1106 for a file name.
1108   If you use @kbd{C-h S} in a major mode that does not support it,
1109 it asks you to specify the ``symbol help mode''.  You should enter
1110 a command such as @code{c-mode} that would select a major
1111 mode which @kbd{C-h S} does support.
1113 @node Man Page
1114 @subsection Man Page Lookup
1116 @cindex man page
1117   On Unix, the main form of on-line documentation was the @dfn{manual
1118 page} or @dfn{man page}.  In the GNU operating system, we aim to
1119 replace man pages with better-organized manuals that you can browse
1120 with Info (@pxref{Misc Help}).  This process is not finished, so it is
1121 still useful to read manual pages.
1123 @findex manual-entry
1124   You can read the man page for an operating system command, library
1125 function, or system call, with the @kbd{M-x man} command.  This
1126 prompts for a topic, with completion (@pxref{Completion}), and runs
1127 the @command{man} program to format the corresponding man page.  If
1128 the system permits, it runs @command{man} asynchronously, so that you
1129 can keep on editing while the page is being formatted.  The result
1130 goes in a buffer named @file{*Man @var{topic}*}.  These buffers use a
1131 special major mode, Man mode, that facilitates scrolling and jumping
1132 to other manual pages.  For details, type @kbd{C-h m} while in a Man
1133 mode buffer.
1135 @cindex sections of manual pages
1136   Each man page belongs to one of ten or more @dfn{sections}, each
1137 named by a digit or by a digit and a letter.  Sometimes there are man
1138 pages with the same name in different sections.  To read a man page
1139 from a specific section, type @samp{@var{topic}(@var{section})} or
1140 @samp{@var{section} @var{topic}} when @kbd{M-x manual-entry} prompts
1141 for the topic.  For example, the man page for the C library function
1142 @code{chmod} is in section 2, but there is a shell command of the same
1143 name, whose man page is in section 1; to view the former, type
1144 @kbd{M-x manual-entry @key{RET} chmod(2) @key{RET}}.
1146 @vindex Man-switches
1147 @kindex M-n @r{(Man mode)}
1148 @kindex M-p @r{(Man mode)}
1149   If you do not specify a section, @kbd{M-x man} normally displays
1150 only the first man page found.  On some systems, the @code{man}
1151 program accepts a @samp{-a} command-line option, which tells it to
1152 display all the man pages for the specified topic.  To make use of
1153 this, change the value of the variable @code{Man-switches} to
1154 @samp{"-a"}.  Then, in the Man mode buffer, you can type @kbd{M-n} and
1155 @kbd{M-p} to switch between man pages in different sections.  The mode
1156 line shows how many manual pages are available.
1158 @findex woman
1159 @cindex manual pages, on MS-DOS/MS-Windows
1160   An alternative way of reading manual pages is the @kbd{M-x woman}
1161 command.  Unlike @kbd{M-x man}, it does not run any external programs
1162 to format and display the man pages; the formatting is done by Emacs,
1163 so it works on systems such as MS-Windows where the @command{man}
1164 program may be unavailable.  It prompts for a man page, and displays
1165 it in a buffer named @file{*WoMan @var{section} @var{topic}}.
1167   @kbd{M-x woman} computes the completion list for manpages the first
1168 time you invoke the command.  With a numeric argument, it recomputes
1169 this list; this is useful if you add or delete manual pages.
1171   If you type a name of a manual page and @kbd{M-x woman} finds that
1172 several manual pages by the same name exist in different sections, it
1173 pops up a window with possible candidates asking you to choose one of
1174 them.
1176   For more information about setting up and using @kbd{M-x woman}, see
1177 @ifinfo
1178 @ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The
1179 WoMan Manual}.
1180 @end ifinfo
1181 @ifnotinfo
1182 the WoMan Info manual, which is distributed with Emacs.
1183 @end ifnotinfo
1185 @node Lisp Doc
1186 @subsection Emacs Lisp Documentation Lookup
1188   When editing Emacs Lisp code, you can use the commands @kbd{C-h f}
1189 (@code{describe-function}) and @kbd{C-h v} (@code{describe-variable})
1190 to view the built-in documentation for the Lisp functions and
1191 variables that you want to use.  @xref{Name Help}.
1193 @cindex Eldoc mode
1194 @findex eldoc-mode
1195   Eldoc is a buffer-local minor mode that helps with looking up Lisp
1196 documention.  When it is enabled, the echo area displays some useful
1197 information whenever there is a Lisp function or variable at point;
1198 for a function, it shows the argument list, and for a variable it
1199 shows the first line of the variable's documentation string.  To
1200 toggle Eldoc mode, type @kbd{M-x eldoc-mode}.  Eldoc mode can be used
1201 with the Emacs Lisp and Lisp Interaction major modes.
1203 @node Hideshow
1204 @section Hideshow minor mode
1205 @cindex Hideshow mode
1206 @cindex mode, Hideshow
1208 @findex hs-minor-mode
1209   Hideshow mode is a buffer-local minor mode that allows you to
1210 selectively display portions of a program, which are referred to as
1211 @dfn{blocks}.  Type @kbd{M-x hs-minor-mode} to toggle this minor mode
1212 (@pxref{Minor Modes}).
1214   When you use Hideshow mode to hide a block, the block disappears
1215 from the screen, to be replaced by an ellipsis (three periods in a
1216 row).  Just what constitutes a block depends on the major mode.  In C
1217 mode and related modes, blocks are delimited by braces, while in Lisp
1218 mode they are delimited by parentheses.  Multi-line comments also
1219 count as blocks.
1221   Hideshow mode provides the following commands:
1223 @findex hs-hide-all
1224 @findex hs-hide-block
1225 @findex hs-show-all
1226 @findex hs-show-block
1227 @findex hs-show-region
1228 @findex hs-hide-level
1229 @findex hs-minor-mode
1230 @kindex C-c @@ C-h
1231 @kindex C-c @@ C-s
1232 @kindex C-c @@ C-M-h
1233 @kindex C-c @@ C-M-s
1234 @kindex C-c @@ C-r
1235 @kindex C-c @@ C-l
1236 @kindex S-Mouse-2
1237 @table @kbd
1238 @item C-c @@ C-h
1239 Hide the current block (@code{hs-hide-block}).
1240 @item C-c @@ C-s
1241 Show the current block (@code{hs-show-block}).
1242 @item C-c @@ C-c
1243 Either hide or show the current block (@code{hs-toggle-hiding}).
1244 @item S-Mouse-2
1245 Toggle hiding for the block you click on (@code{hs-mouse-toggle-hiding}).
1246 @item C-c @@ C-M-h
1247 Hide all top-level blocks (@code{hs-hide-all}).
1248 @item C-c @@ C-M-s
1249 Show all blocks in the buffer (@code{hs-show-all}).
1250 @item C-c @@ C-l
1251 Hide all blocks @var{n} levels below this block
1252 (@code{hs-hide-level}).
1253 @end table
1255 @vindex hs-hide-comments-when-hiding-all
1256 @vindex hs-isearch-open
1257 @vindex hs-special-modes-alist
1258   These variables can be used to customize Hideshow mode:
1260 @table @code
1261 @item hs-hide-comments-when-hiding-all
1262 If non-@code{nil}, @kbd{C-c @@ C-M-h} (@code{hs-hide-all}) hides
1263 comments too.
1265 @item hs-isearch-open
1266 This variable specifies the conditions under which incremental search
1267 should unhide a hidden block when matching text occurs within the
1268 block.  Its value should be either @code{code} (unhide only code
1269 blocks), @code{comment} (unhide only comments), @code{t} (unhide both
1270 code blocks and comments), or @code{nil} (unhide neither code blocks
1271 nor comments).  The default value is @code{code}.
1272 @end table
1274 @node Symbol Completion
1275 @section Completion for Symbol Names
1276 @cindex completion (symbol names)
1278   Completion is normally done in the minibuffer (@pxref{Completion}),
1279 but you can also complete symbol names in ordinary Emacs buffers.
1281 @kindex M-TAB
1282 @kindex C-M-i
1283   In programming language modes, type @kbd{C-M-i} or @kbd{M-@key{TAB}}
1284 to complete the partial symbol before point.  On graphical displays,
1285 the @kbd{M-@key{TAB}} key is usually reserved by the window manager
1286 for switching graphical windows, so you should type @kbd{C-M-i} or
1287 @kbd{@key{ESC} @key{TAB}} instead.
1289 @cindex tags-based completion
1290 @findex completion-at-point
1291 @cindex Lisp symbol completion
1292 @cindex completion (Lisp symbols)
1293   In most programming language modes, @kbd{C-M-i} (or
1294 @kbd{M-@key{TAB}}) invokes the command @code{completion-at-point},
1295 which generates its completion list in a flexible way.  If Semantic
1296 mode is enabled, it tries to use the Semantic parser data for
1297 completion (@pxref{Semantic}).  If Semantic mode is not enabled or
1298 fails at performing completion, it tries to complete using the
1299 selected tags table (@pxref{Tags}).  If in Emacs Lisp mode, it
1300 performs completion using the function, variable, or property names
1301 defined in the current Emacs session.
1303   In all other respects, in-buffer symbol completion behaves like
1304 minibuffer completion.  For instance, if Emacs cannot complete to a
1305 unique symbol, it displays a list of completion alternatives in
1306 another window.  @xref{Completion}.
1308   In Text mode and related modes, @kbd{M-@key{TAB}} completes words
1309 based on the spell-checker's dictionary.  @xref{Spelling}.
1311 @node Glasses
1312 @section Glasses minor mode
1313 @cindex Glasses mode
1314 @cindex camel case
1315 @findex mode, Glasses
1317   Glasses mode is a buffer-local minor mode that makes it easier to
1318 read mixed-case (or ``CamelCase'') symbols like
1319 @samp{unReadableSymbol}, by altering how they are displayed.  By
1320 default, it displays extra underscores between each lower-case letter
1321 and the following capital letter.  This does not alter the buffer
1322 text, only how it is displayed.
1324   To toggle Glasses mode, type @kbd{M-x glasses-mode} (@pxref{Minor
1325 Modes}).  When Glasses mode is enabled, the minor mode indicator
1326 @samp{o^o} appears in the mode line.  For more information about
1327 Glasses mode, type @kbd{C-h P glasses @key{RET}}.
1329 @node Semantic
1330 @section Semantic
1331 @cindex Semantic package
1333 Semantic is a package that provides language-aware editing commands
1334 based on @code{source code parsers}.  This section provides a brief
1335 description of Semantic; for full details,
1336 @ifnottex
1337 see @ref{Top, Semantic,, semantic, Semantic}.
1338 @end ifnottex
1339 @iftex
1340 see the Semantic Info manual, which is distributed with Emacs.
1341 @end iftex
1343   Most of the ``language aware'' features in Emacs, such as Font Lock
1344 mode (@pxref{Font Lock}), rely on ``rules of thumb''@footnote{Regular
1345 expressions and syntax tables.} that usually give good results but are
1346 never completely exact.  In contrast, the parsers used by Semantic
1347 have an exact understanding of programming language syntax.  This
1348 allows Semantic to provide search, navigation, and completion commands
1349 that are powerful and precise.
1351 @cindex Semantic mode
1352 @cindex mode, Semantic
1353   To begin using Semantic, type @kbd{M-x semantic-mode} or click on
1354 the menu item named @samp{Source Code Parsers (Semantic)} in the
1355 @samp{Tools} menu.  This enables Semantic mode, a global minor mode.
1357    When Semantic mode is enabled, Emacs automatically attempts to
1358 parses each file you visit.  Currently, Semantic understands C, C++,
1359 Scheme, Javascript, Java, HTML, and Make.  Within each parsed buffer,
1360 the following commands are available:
1362 @table @kbd
1363 @item C-c , j
1364 @kindex C-c , j
1365 Prompt for the name of a function defined in the current file, and
1366 move point there (@code{semantic-complete-jump-local}).
1368 @item C-c , J
1369 @kindex C-c , J
1370 Prompt for the name of a function defined in any file Emacs has
1371 parsed, and move point there (@code{semantic-complete-jump}).
1373 @item C-c , @key{SPC}
1374 @kindex C-c , @key{SPC}
1375 Display a list of possible completions for the symbol at point
1376 (@code{semantic-complete-analyze-inline}).  This also activates a set
1377 of special key bindings for choosing a completion: @key{RET} accepts
1378 the current completion, @kbd{M-n} and @kbd{M-p} cycle through possible
1379 completions, @key{TAB} completes as far as possible and then cycles,
1380 and @kbd{C-g} or any other key aborts completion.
1382 @item C-c , l
1383 @kindex C-c , l
1384 Display a list of the possible completions of the symbol at point, in
1385 another window (@code{semantic-analyze-possible-completions}).
1386 @end table
1388 @noindent
1389 In addition to the above commands, the Semantic package provides a
1390 variety of other ways to make use of parser information.  For
1391 instance, you can use it to display a list of completions when Emacs
1392 is idle.
1393 @ifnottex
1394 @xref{Top, Semantic,, semantic, Semantic}, for details.
1395 @end ifnottex
1397 @node Misc for Programs
1398 @section Other Features Useful for Editing Programs
1400   Some Emacs commands that aren't designed specifically for editing
1401 programs are useful for that nonetheless.
1403   The Emacs commands that operate on words, sentences and paragraphs
1404 are useful for editing code.  Most symbols names contain words
1405 (@pxref{Words}), while sentences can be found in strings and comments
1406 (@pxref{Sentences}).  As for paragraphs, they are defined in most
1407 programming language modes to begin and end at blank lines
1408 (@pxref{Paragraphs}).  Therefore, judicious use of blank lines to make
1409 the program clearer will also provide useful chunks of text for the
1410 paragraph commands to work on.  Auto Fill mode, if enabled in a
1411 programming language major mode, indents the new lines which it
1412 creates.
1414 @findex electric-layout-mode
1415   Electric Layout mode (@kbd{M-x electric-layout-mode}) is a global
1416 minor mode that automatically inserts newlines when you type certain
1417 characters; for example, @samp{@{}, @samp{@}} and @samp{;} in Javascript
1418 mode.
1420   Apart from Hideshow mode (@pxref{Hideshow}), another way to
1421 selectively display parts of a program is to use the selective display
1422 feature (@pxref{Selective Display}).  Programming modes often also
1423 support Outline minor mode (@pxref{Outline Mode}), which can be used
1424 with the Foldout package (@pxref{Foldout}).
1426 @ifinfo
1427   The ``automatic typing'' features may be useful for writing programs.
1428 @xref{Top,,Autotyping, autotype, Autotyping}.
1429 @end ifinfo
1431 @node C Modes
1432 @section C and Related Modes
1433 @cindex C mode
1434 @cindex Java mode
1435 @cindex Pike mode
1436 @cindex IDL mode
1437 @cindex CORBA IDL mode
1438 @cindex Objective C mode
1439 @cindex C++ mode
1440 @cindex AWK mode
1441 @cindex mode, Java
1442 @cindex mode, C
1443 @cindex mode, C++
1444 @cindex mode, Objective C
1445 @cindex mode, CORBA IDL
1446 @cindex mode, Pike
1447 @cindex mode, AWK
1449   This section gives a brief description of the special features
1450 available in C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes.
1451 (These are called ``C mode and related modes''.)
1452 @ifinfo
1453 @xref{Top,, CC Mode, ccmode, CC Mode}, for more details.
1454 @end ifinfo
1455 @ifnotinfo
1456 For more details, see the CC mode Info manual, which is distributed
1457 with Emacs.
1458 @end ifnotinfo
1460 @menu
1461 * Motion in C::                 Commands to move by C statements, etc.
1462 * Electric C::                  Colon and other chars can automatically reindent.
1463 * Hungry Delete::               A more powerful DEL command.
1464 * Other C Commands::            Filling comments, viewing expansion of macros,
1465                                 and other neat features.
1466 @end menu
1468 @node Motion in C
1469 @subsection C Mode Motion Commands
1471   This section describes commands for moving point, in C mode and
1472 related modes.
1474 @table @code
1475 @item C-M-a
1476 @itemx C-M-e
1477 @findex c-beginning-of-defun
1478 @findex c-end-of-defun
1479 Move point to the beginning or end of the current function or
1480 top-level definition.  In languages with enclosing scopes (such as
1481 C++'s classes) the @dfn{current function} is the immediate one,
1482 possibly inside a scope.  Otherwise it is the one defined by the least
1483 enclosing braces.  (By contrast, @code{beginning-of-defun} and
1484 @code{end-of-defun} search for braces in column zero.)  @xref{Moving
1485 by Defuns}.
1487 @item C-c C-u
1488 @kindex C-c C-u @r{(C mode)}
1489 @findex c-up-conditional
1490 Move point back to the containing preprocessor conditional, leaving the
1491 mark behind.  A prefix argument acts as a repeat count.  With a negative
1492 argument, move point forward to the end of the containing
1493 preprocessor conditional.
1495 @samp{#elif} is equivalent to @samp{#else} followed by @samp{#if}, so
1496 the function will stop at a @samp{#elif} when going backward, but not
1497 when going forward.
1499 @item C-c C-p
1500 @kindex C-c C-p @r{(C mode)}
1501 @findex c-backward-conditional
1502 Move point back over a preprocessor conditional, leaving the mark
1503 behind.  A prefix argument acts as a repeat count.  With a negative
1504 argument, move forward.
1506 @item C-c C-n
1507 @kindex C-c C-n @r{(C mode)}
1508 @findex c-forward-conditional
1509 Move point forward across a preprocessor conditional, leaving the mark
1510 behind.  A prefix argument acts as a repeat count.  With a negative
1511 argument, move backward.
1513 @item M-a
1514 @kindex M-a (C mode)
1515 @findex c-beginning-of-statement
1516 Move point to the beginning of the innermost C statement
1517 (@code{c-beginning-of-statement}).  If point is already at the beginning
1518 of a statement, move to the beginning of the preceding statement.  With
1519 prefix argument @var{n}, move back @var{n} @minus{} 1 statements.
1521 In comments or in strings which span more than one line, this command
1522 moves by sentences instead of statements.
1524 @item M-e
1525 @kindex M-e (C mode)
1526 @findex c-end-of-statement
1527 Move point to the end of the innermost C statement or sentence; like
1528 @kbd{M-a} except that it moves in the other direction
1529 (@code{c-end-of-statement}).
1530 @end table
1532 @node Electric C
1533 @subsection Electric C Characters
1535   In C mode and related modes, certain printing characters are
1536 @dfn{electric}---in addition to inserting themselves, they also
1537 reindent the current line, and optionally also insert newlines.  The
1538 ``electric'' characters are @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#},
1539 @kbd{;}, @kbd{,}, @kbd{<}, @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and
1540 @kbd{)}.
1542   You might find electric indentation inconvenient if you are editing
1543 chaotically indented code.  If you are new to CC Mode, you might find
1544 it disconcerting.  You can toggle electric action with the command
1545 @kbd{C-c C-l}; when it is enabled, @samp{/l} appears in the mode line
1546 after the mode name:
1548 @table @kbd
1549 @item C-c C-l
1550 @kindex C-c C-l @r{(C mode)}
1551 @findex c-toggle-electric-state
1552 Toggle electric action (@code{c-toggle-electric-state}).  With a
1553 positive prefix argument, this command enables electric action, with a
1554 negative one it disables it.
1555 @end table
1557   Electric characters insert newlines only when, in addition to the
1558 electric state, the @dfn{auto-newline} feature is enabled (indicated
1559 by @samp{/la} in the mode line after the mode name).  You can turn
1560 this feature on or off with the command @kbd{C-c C-a}:
1562 @table @kbd
1563 @item C-c C-a
1564 @kindex C-c C-a @r{(C mode)}
1565 @findex c-toggle-auto-newline
1566 Toggle the auto-newline feature (@code{c-toggle-auto-newline}).  With a
1567 prefix argument, this command turns the auto-newline feature on if the
1568 argument is positive, and off if it is negative.
1569 @end table
1571   Usually the CC Mode style configures the exact circumstances in
1572 which Emacs inserts auto-newlines.  You can also configure this
1573 directly.  @xref{Custom Auto-newlines,,, ccmode, The CC Mode Manual}.
1575 @node Hungry Delete
1576 @subsection Hungry Delete Feature in C
1577 @cindex hungry deletion (C Mode)
1579   If you want to delete an entire block of whitespace at point, you
1580 can use @dfn{hungry deletion}.  This deletes all the contiguous
1581 whitespace either before point or after point in a single operation.
1582 @dfn{Whitespace} here includes tabs and newlines, but not comments or
1583 preprocessor commands.
1585 @table @kbd
1586 @item C-c C-@key{DEL}
1587 @itemx C-c @key{DEL}
1588 @findex c-hungry-delete-backwards
1589 @kindex C-c C-@key{DEL} (C Mode)
1590 @kindex C-c @key{DEL} (C Mode)
1591 Delete the entire block of whitespace preceding point (@code{c-hungry-delete-backwards}).
1593 @item C-c C-d
1594 @itemx C-c C-@key{DELETE}
1595 @itemx C-c @key{DELETE}
1596 @findex c-hungry-delete-forward
1597 @kindex C-c C-d (C Mode)
1598 @kindex C-c C-@key{DELETE} (C Mode)
1599 @kindex C-c @key{DELETE} (C Mode)
1600 Delete the entire block of whitespace after point (@code{c-hungry-delete-forward}).
1601 @end table
1603   As an alternative to the above commands, you can enable @dfn{hungry
1604 delete mode}.  When this feature is enabled (indicated by @samp{/h} in
1605 the mode line after the mode name), a single @key{DEL} deletes all
1606 preceding whitespace, not just one space, and a single @kbd{C-c C-d}
1607 (but @emph{not} plain @key{DELETE}) deletes all following whitespace.
1609 @table @kbd
1610 @item M-x c-toggle-hungry-state
1611 @findex c-toggle-hungry-state
1612 Toggle the hungry-delete feature
1613 (@code{c-toggle-hungry-state}).  With a prefix argument,
1614 this command turns the hungry-delete feature on if the argument is
1615 positive, and off if it is negative.
1616 @end table
1618 @vindex c-hungry-delete-key
1619    The variable @code{c-hungry-delete-key} controls whether the
1620 hungry-delete feature is enabled.
1622 @node Other C Commands
1623 @subsection Other Commands for C Mode
1625 @table @kbd
1626 @item C-c C-w
1627 @itemx M-x subword-mode
1628 @findex subword-mode
1629 Enable (or disable) @dfn{subword mode}.  In subword mode, Emacs's word
1630 commands recognize upper case letters in
1631 @samp{StudlyCapsIdentifiers} as word boundaries.  This is indicated by
1632 the flag @samp{/w} on the mode line after the mode name
1633 (e.g. @samp{C/law}).  You can even use @kbd{M-x subword-mode} in
1634 non-CC Mode buffers.
1636 In the GNU project, we recommend using underscores to separate words
1637 within an identifier in C or C++, rather than using case distinctions.
1639 @item M-x c-context-line-break
1640 @findex c-context-line-break
1641 This command inserts a line break and indents the new line in a manner
1642 appropriate to the context.  In normal code, it does the work of
1643 @kbd{C-j} (@code{newline-and-indent}), in a C preprocessor line it
1644 additionally inserts a @samp{\} at the line break, and within comments
1645 it's like @kbd{M-j} (@code{c-indent-new-comment-line}).
1647 @code{c-context-line-break} isn't bound to a key by default, but it
1648 needs a binding to be useful.  The following code will bind it to
1649 @kbd{C-j}.  We use @code{c-initialization-hook} here to make sure
1650 the keymap is loaded before we try to change it.
1652 @example
1653 (defun my-bind-clb ()
1654   (define-key c-mode-base-map "\C-j" 'c-context-line-break))
1655 (add-hook 'c-initialization-hook 'my-bind-clb)
1656 @end example
1658 @item C-M-h
1659 Put mark at the end of a function definition, and put point at the
1660 beginning (@code{c-mark-function}).
1662 @item M-q
1663 @kindex M-q @r{(C mode)}
1664 @findex c-fill-paragraph
1665 Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}).
1666 If any part of the current line is a comment or within a comment, this
1667 command fills the comment or the paragraph of it that point is in,
1668 preserving the comment indentation and comment delimiters.
1670 @item C-c C-e
1671 @cindex macro expansion in C
1672 @cindex expansion of C macros
1673 @findex c-macro-expand
1674 @kindex C-c C-e @r{(C mode)}
1675 Run the C preprocessor on the text in the region, and show the result,
1676 which includes the expansion of all the macro calls
1677 (@code{c-macro-expand}).  The buffer text before the region is also
1678 included in preprocessing, for the sake of macros defined there, but the
1679 output from this part isn't shown.
1681 When you are debugging C code that uses macros, sometimes it is hard to
1682 figure out precisely how the macros expand.  With this command, you
1683 don't have to figure it out; you can see the expansions.
1685 @item C-c C-\
1686 @findex c-backslash-region
1687 @kindex C-c C-\ @r{(C mode)}
1688 Insert or align @samp{\} characters at the ends of the lines of the
1689 region (@code{c-backslash-region}).  This is useful after writing or
1690 editing a C macro definition.
1692 If a line already ends in @samp{\}, this command adjusts the amount of
1693 whitespace before it.  Otherwise, it inserts a new @samp{\}.  However,
1694 the last line in the region is treated specially; no @samp{\} is
1695 inserted on that line, and any @samp{\} there is deleted.
1697 @item M-x cpp-highlight-buffer
1698 @cindex preprocessor highlighting
1699 @findex cpp-highlight-buffer
1700 Highlight parts of the text according to its preprocessor conditionals.
1701 This command displays another buffer named @file{*CPP Edit*}, which
1702 serves as a graphic menu for selecting how to display particular kinds
1703 of conditionals and their contents.  After changing various settings,
1704 click on @samp{[A]pply these settings} (or go to that buffer and type
1705 @kbd{a}) to rehighlight the C mode buffer accordingly.
1707 @item C-c C-s
1708 @findex c-show-syntactic-information
1709 @kindex C-c C-s @r{(C mode)}
1710 Display the syntactic information about the current source line
1711 (@code{c-show-syntactic-information}).  This information directs how
1712 the line is indented.
1714 @item M-x cwarn-mode
1715 @itemx M-x global-cwarn-mode
1716 @findex cwarn-mode
1717 @findex global-cwarn-mode
1718 @vindex global-cwarn-mode
1719 @cindex CWarn mode
1720 @cindex suspicious constructions in C, C++
1721 CWarn minor mode highlights certain suspicious C and C++ constructions:
1723 @itemize @bullet{}
1724 @item
1725 Assignments inside expressions.
1726 @item
1727 Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while}
1728 (except after a @samp{do @dots{} while} statement);
1729 @item
1730 C++ functions with reference parameters.
1731 @end itemize
1733 @noindent
1734 You can enable the mode for one buffer with the command @kbd{M-x
1735 cwarn-mode}, or for all suitable buffers with the command @kbd{M-x
1736 global-cwarn-mode} or by customizing the variable
1737 @code{global-cwarn-mode}.  You must also enable Font Lock mode to make
1738 it work.
1740 @item M-x hide-ifdef-mode
1741 @findex hide-ifdef-mode
1742 @cindex Hide-ifdef mode
1743 @vindex hide-ifdef-shadow
1744 Hide-ifdef minor mode hides selected code within @samp{#if} and
1745 @samp{#ifdef} preprocessor blocks.  If you change the variable
1746 @code{hide-ifdef-shadow} to @code{t}, Hide-ifdef minor mode
1747 ``shadows'' preprocessor blocks by displaying them with a less
1748 prominent face, instead of hiding them entirely.  See the
1749 documentation string of @code{hide-ifdef-mode} for more information.
1751 @item M-x ff-find-related-file
1752 @cindex related files
1753 @findex ff-find-related-file
1754 @vindex ff-related-file-alist
1755 Find a file ``related'' in a special way to the file visited by the
1756 current buffer.  Typically this will be the header file corresponding
1757 to a C/C++ source file, or vice versa.  The variable
1758 @code{ff-related-file-alist} specifies how to compute related file
1759 names.
1760 @end table
1762 @node Asm Mode
1763 @section Asm Mode
1765 @cindex Asm mode
1766 @cindex assembler mode
1767 Asm mode is a major mode for editing files of assembler code.  It
1768 defines these commands:
1770 @table @kbd
1771 @item @key{TAB}
1772 @code{tab-to-tab-stop}.
1773 @item C-j
1774 Insert a newline and then indent using @code{tab-to-tab-stop}.
1775 @item :
1776 Insert a colon and then remove the indentation from before the label
1777 preceding colon.  Then do @code{tab-to-tab-stop}.
1778 @item ;
1779 Insert or align a comment.
1780 @end table
1782   The variable @code{asm-comment-char} specifies which character
1783 starts comments in assembler syntax.
1785 @ifnottex
1786 @include fortran-xtra.texi
1787 @end ifnottex