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