comparison man/programs.texi @ 89943:4c90ffeb71c5

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 28 Jun 2004 07:56:49 +0000
parents 68c22ea6027c f5e9166d3954
children 3219f94257bc
comparison
equal deleted inserted replaced
89942:9cb747ae49af 89943:4c90ffeb71c5
63 and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}. 63 and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}.
64 @xref{Choosing Modes}. 64 @xref{Choosing Modes}.
65 65
66 @cindex Perl mode 66 @cindex Perl mode
67 @cindex Icon mode 67 @cindex Icon mode
68 @cindex Awk mode
69 @cindex Makefile mode 68 @cindex Makefile mode
70 @cindex Tcl mode 69 @cindex Tcl mode
71 @cindex CPerl mode 70 @cindex CPerl mode
72 @cindex DSSSL mode 71 @cindex DSSSL mode
73 @cindex Octave mode 72 @cindex Octave mode
80 @cindex Shell-script mode 79 @cindex Shell-script mode
81 @cindex Delphi mode 80 @cindex Delphi mode
82 @cindex PostScript mode 81 @cindex PostScript mode
83 The existing programming language major modes include Lisp, Scheme (a 82 The existing programming language major modes include Lisp, Scheme (a
84 variant of Lisp) and the Scheme-based DSSSL expression language, Ada, 83 variant of Lisp) and the Scheme-based DSSSL expression language, Ada,
85 Awk, C, C++, Delphi (Object Pascal), Fortran (free format and fixed 84 AWK, C, C++, Delphi (Object Pascal), Fortran (free format and fixed
86 format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s 85 format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s
87 companion for font creation), Modula2, Objective-C, Octave, Pascal, 86 companion for font creation), Modula2, Objective-C, Octave, Pascal,
88 Perl, Pike, PostScript, Prolog, Simula, Tcl, and VHDL. There is 87 Perl, Pike, PostScript, Prolog, Simula, Tcl, and VHDL. There is
89 also a major mode for makefiles, called Makefile mode. An alternative 88 also a major mode for makefiles, called Makefile mode. An alternative
90 mode for Perl is called CPerl mode. Modes are available for the 89 mode for Perl is called CPerl mode. Modes are available for the
102 delete one column of indentation without worrying whether the 101 delete one column of indentation without worrying whether the
103 whitespace consists of spaces or tabs. Use @kbd{C-b C-d} to delete a 102 whitespace consists of spaces or tabs. Use @kbd{C-b C-d} to delete a
104 tab character before point, in these modes. 103 tab character before point, in these modes.
105 104
106 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada 105 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada
107 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL 106 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL/Pike/AWK
108 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes 107 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes
109 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). 108 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}).
110 109
111 @cindex mode hook 110 @cindex mode hook
112 @vindex c-mode-hook 111 @vindex c-mode-hook
444 reindent the whole grouping as a rigid unit. (This works in Lisp 443 reindent the whole grouping as a rigid unit. (This works in Lisp
445 modes and C and related modes.) @key{TAB} with a numeric argument 444 modes and C and related modes.) @key{TAB} with a numeric argument
446 reindents the current line as usual, then reindents by the same amount 445 reindents the current line as usual, then reindents by the same amount
447 all the lines in the parenthetical grouping starting on the current 446 all the lines in the parenthetical grouping starting on the current
448 line. It is clever, though, and does not alter lines that start 447 line. It is clever, though, and does not alter lines that start
449 inside strings, or C preprocessor lines when in C mode. 448 inside strings. Neither does it alter C preprocessor lines when in C
449 mode, but it does reindent any continuation lines that may be attached
450 to them.
450 451
451 @findex indent-code-rigidly 452 @findex indent-code-rigidly
452 You can also perform this operation on the region, using the command 453 You can also perform this operation on the region, using the command
453 @kbd{M-x indent-code-rigidly}. It rigidly shifts all the lines in the 454 @kbd{M-x indent-code-rigidly}. It rigidly shifts all the lines in the
454 region sideways, like @code{indent-rigidly} does (@pxref{Indentation 455 region sideways, like @code{indent-rigidly} does (@pxref{Indentation
455 Commands}). It doesn't alter the indentation of lines that start 456 Commands}). It doesn't alter the indentation of lines that start
456 inside a comment or a string, unless the region starts inside that 457 inside a string, unless the region also starts inside that string.
457 comment or string.
458 458
459 @node Lisp Indent 459 @node Lisp Indent
460 @subsection Customizing Lisp Indentation 460 @subsection Customizing Lisp Indentation
461 @cindex customizing Lisp indentation 461 @cindex customizing Lisp indentation
462 462
505 505
506 @item C-M-q 506 @item C-M-q
507 @kindex C-M-q @r{(C mode)} 507 @kindex C-M-q @r{(C mode)}
508 @findex c-indent-exp 508 @findex c-indent-exp
509 Reindent each line in the balanced expression that follows point 509 Reindent each line in the balanced expression that follows point
510 (@code{c-indent-exp}). A prefix argument inhibits error checking and 510 (@code{c-indent-exp}). A prefix argument inhibits warning messages
511 warning messages about invalid syntax. 511 about invalid syntax.
512 512
513 @item @key{TAB} 513 @item @key{TAB}
514 @findex c-indent-command 514 @findex c-indent-command
515 Reindent the current line, and/or in some cases insert a tab character 515 Reindent the current line, and/or in some cases insert a tab character
516 (@code{c-indent-command}). 516 (@code{c-indent-command}).
517 517
518 @vindex c-tab-always-indent
518 If @code{c-tab-always-indent} is @code{t}, this command always reindents 519 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. 520 the current line and does nothing else. This is the default.
520 521
521 If that variable is @code{nil}, this command reindents the current line 522 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 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 otherwise, it inserts a tab (or the equivalent number of spaces,
524 if @code{indent-tabs-mode} is @code{nil}). 525 if @code{indent-tabs-mode} is @code{nil}).
525 526
526 Any other value (not @code{nil} or @code{t}) means always reindent the 527 Any other value (not @code{nil} or @code{t}) means always reindent the
527 line, and also insert a tab if within a comment, a string, or a 528 line, and also insert a tab if within a comment or a string.
528 preprocessor directive.
529 @end table 529 @end table
530 530
531 To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This 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 532 first selects the whole buffer as the region, then reindents that
533 region. 533 region.
537 537
538 @node Custom C Indent 538 @node Custom C Indent
539 @subsection Customizing C Indentation 539 @subsection Customizing C Indentation
540 @cindex style (for indentation) 540 @cindex style (for indentation)
541 541
542 C mode and related modes use a simple yet flexible mechanism for 542 C mode and related modes use a flexible mechanism for customizing
543 customizing indentation. The mechanism works in two steps: first it 543 indentation. C mode indents a source line in two steps: first it
544 classifies the line syntactically according to its contents and context; 544 classifies the line syntactically according to its contents and
545 second, it associates each kind of syntactic construct with an 545 context; second, it determines the indentation offset associated by
546 indentation offset based on your selected @dfn{style}. 546 your selected @dfn{style} with the syntactic construct and adds this
547 onto the indentation of the @dfn{anchor statement}.
547 548
548 @table @kbd 549 @table @kbd
549 @item M-x c-set-style @key{RET} @var{style} @key{RET} 550 @item C-c . @key{RET} @var{style} @key{RET}
550 Select predefined indentation style @var{style}. 551 Select a predefined style @var{style} (@code{c-set-style}).
551 @end table 552 @end table
552 553
553 A style is a named collection of indentation customizations that can 554 A @dfn{style} is a named collection of customizations that can
554 be used in C mode and the related modes. Emacs comes with several 555 be used in C mode and the related modes. Emacs comes with several
555 predefined styles, including @code{gnu}, @code{k&r}, @code{bsd}, 556 predefined styles, including @code{gnu}, @code{k&r}, @code{bsd},
556 @code{stroustrup}, @code{linux}, @code{python}, @code{java}, 557 @code{stroustrup}, @code{linux}, @code{python}, @code{java},
557 @code{whitesmith}, @code{ellemtel}, @code{cc-mode}, and @code{user}. 558 @code{whitesmith}, @code{ellemtel}, @code{cc-mode}, and @code{user}.
558 Some of these styles are primarily intended for one language, but any 559 Some of these styles are primarily intended for one language, but any
559 of them can be used with any of the languages supported by these 560 of them can be used with any of the languages supported by these
560 modes. To find out what a style looks like, select it and reindent 561 modes. To find out what a style looks like, select it and reindent
561 some code, e.g., by typing @key{C-M-q} at the start of a function 562 some code, e.g., by typing @key{C-M-q} at the start of a function
562 definition. 563 definition.
563 564
565 @kindex C-c . @r{(C mode)}
564 @findex c-set-style 566 @findex c-set-style
565 To choose a style for the current buffer, use the command @kbd{M-x 567 To choose a style for the current buffer, use the command @kbd{C-c
566 c-set-style}. Specify a style name as an argument (case is not 568 .}. Specify a style name as an argument (case is not significant).
567 significant). This command affects the current buffer only, and it 569 This command affects the current buffer only, and it affects only
568 affects only future invocations of the indentation commands; it does 570 future invocations of the indentation commands; it does not reindent
569 not reindent the code in the buffer. To reindent the whole buffer in 571 the code in the buffer. To reindent the whole buffer in the new
570 the new style, you can type @kbd{C-x h C-M-\}. 572 style, you can type @kbd{C-x h C-M-\}.
571 573
572 @vindex c-default-style 574 @vindex c-default-style
573 You can also set the variable @code{c-default-style} to specify the 575 You can also set the variable @code{c-default-style} to specify the
574 default style for various major modes. Its value should be an alist, 576 default style for various major modes. Its value should be either the
575 in which each element specifies one major mode and which indentation 577 style's name (a string) or an alist, in which each element specifies
576 style to use for it. For example, 578 one major mode and which indentation style to use for it. For
579 example,
577 580
578 @example 581 @example
579 (setq c-default-style 582 (setq c-default-style
580 '((java-mode . "java") (other . "gnu"))) 583 '((java-mode . "java") (other . "gnu")))
581 @end example 584 @end example
846 @cindex indentation for comments 849 @cindex indentation for comments
847 850
848 The comment commands in this table insert, kill and align comments. 851 The comment commands in this table insert, kill and align comments.
849 They are described in this section and following sections. 852 They are described in this section and following sections.
850 853
851 @table @kbd 854 @table @asis
852 @item M-; 855 @item @kbd{M-;}
853 Insert or realign comment on current line; alternatively, comment or 856 Insert or realign comment on current line; alternatively, comment or
854 uncomment the region (@code{comment-dwim}). 857 uncomment the region (@code{comment-dwim}).
855 @item C-u M-; 858 @item @kbd{C-u M-;}
856 Kill comment on current line (@code{comment-kill}). 859 Kill comment on current line (@code{comment-kill}).
857 @item C-x ; 860 @item @kbd{C-x ;}
858 Set comment column (@code{comment-set-column}). 861 Set comment column (@code{comment-set-column}).
859 @item C-M-j 862 @item @kbd{C-M-j}
863 @itemx @kbd{M-j}
860 Like @key{RET} followed by inserting and aligning a comment 864 Like @key{RET} followed by inserting and aligning a comment
861 (@code{comment-indent-new-line}). 865 (@code{comment-indent-new-line}).
862 @item M-x comment-region 866 @item @kbd{M-x comment-region}
867 @itemx @kbd{C-c C-c} (in C-like modes)
863 Add or remove comment delimiters on all the lines in the region. 868 Add or remove comment delimiters on all the lines in the region.
864 @end table 869 @end table
865 870
866 @kindex M-; 871 @kindex M-;
867 @findex comment-dwim 872 @findex comment-dwim
935 940
936 @node Multi-Line Comments 941 @node Multi-Line Comments
937 @subsection Multiple Lines of Comments 942 @subsection Multiple Lines of Comments
938 943
939 @kindex C-M-j 944 @kindex C-M-j
945 @kindex M-j
940 @cindex blank lines in programs 946 @cindex blank lines in programs
941 @findex comment-indent-new-line 947 @findex comment-indent-new-line
942 If you are typing a comment and wish to continue it on another line, 948 If you are typing a comment and wish to continue it on another line,
943 you can use the command @kbd{C-M-j} (@code{comment-indent-new-line}). 949 you can use the command @kbd{C-M-j} or @kbd{M-j}
944 This terminates the comment you are typing, creates a new blank line 950 (@code{comment-indent-new-line}). This terminates the comment you are
945 afterward, and begins a new comment indented under the old one. When 951 typing, creates a new blank line afterward, and begins a new comment
946 Auto Fill mode is on, going past the fill column while typing a comment 952 indented under the old one. When Auto Fill mode is on, going past the
947 causes the comment to be continued in just this fashion. If point is 953 fill column while typing a comment causes the comment to be continued
948 not at the end of the line when @kbd{C-M-j} is typed, the text on 954 in just this fashion. If point is not at the end of the line when you
949 the rest of the line becomes part of the new comment line. 955 type the command, the text on the rest of the line becomes part of the
950 956 new comment line.
957
958 @kindex C-c C-c (C mode)
951 @findex comment-region 959 @findex comment-region
952 To turn existing lines into comment lines, use the @kbd{M-x 960 To turn existing lines into comment lines, use the @kbd{M-x
953 comment-region} command. It adds comment delimiters to the lines that start 961 comment-region} command. It adds comment delimiters to the lines that start
954 in the region, thus commenting them out. With a negative argument, it 962 in the region, thus commenting them out. With a negative argument, it
955 does the opposite---it deletes comment delimiters from the lines in the 963 does the opposite---it deletes comment delimiters from the lines in the
968 @subsection Options Controlling Comments 976 @subsection Options Controlling Comments
969 977
970 @vindex comment-column 978 @vindex comment-column
971 @kindex C-x ; 979 @kindex C-x ;
972 @findex comment-set-column 980 @findex comment-set-column
973 The comment column is stored in the variable @code{comment-column}. You 981 The @dfn{comment column}, the column at which Emacs tries to place
974 can set it to a number explicitly. Alternatively, the command @kbd{C-x ;} 982 comments, is stored in the variable @code{comment-column}. You can
975 (@code{comment-set-column}) sets the comment column to the column point is 983 set it to a number explicitly. Alternatively, the command @kbd{C-x ;}
976 at. @kbd{C-u C-x ;} sets the comment column to match the last comment 984 (@code{comment-set-column}) sets the comment column to the column
977 before point in the buffer, and then does a @kbd{M-;} to align the 985 point is at. @kbd{C-u C-x ;} sets the comment column to match the
978 current line's comment under the previous one. 986 last comment before point in the buffer, and then does a @kbd{M-;} to
987 align the current line's comment under the previous one.
979 988
980 The variable @code{comment-column} is per-buffer: setting the variable 989 The variable @code{comment-column} is per-buffer: setting the variable
981 in the normal fashion affects only the current buffer, but there is a 990 in the normal fashion affects only the current buffer, but there is a
982 default value which you can change with @code{setq-default}. 991 default value which you can change with @code{setq-default}.
983 @xref{Locals}. Many major modes initialize this variable for the 992 @xref{Locals}. Many major modes initialize this variable for the
988 expression that is the value of the variable @code{comment-start-skip}. 997 expression that is the value of the variable @code{comment-start-skip}.
989 Make sure this regexp does not match the null string. It may match more 998 Make sure this regexp does not match the null string. It may match more
990 than the comment starting delimiter in the strictest sense of the word; 999 than the comment starting delimiter in the strictest sense of the word;
991 for example, in C mode the value of the variable is 1000 for example, in C mode the value of the variable is
992 @c This stops M-q from breaking the line inside that @code. 1001 @c This stops M-q from breaking the line inside that @code.
993 @code{@w{"/\\*+ *\\|//+ *""}}, which matches extra stars and spaces 1002 @code{@w{"/\\*+ *\\|//+ *"}}, which matches extra stars and spaces
994 after the @samp{/*} itself, and accepts C++ style comments also. 1003 after the @samp{/*} itself, and accepts C++ style comments also.
995 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in 1004 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in
996 the string, which is needed to deny the first star its special meaning 1005 the string, which is needed to deny the first star its special meaning
997 in regexp syntax. @xref{Regexps}.) 1006 in regexp syntax. @xref{Regexps}.)
998 1007
1004 into the comment. In C mode, @code{comment-start} has the value 1013 into the comment. In C mode, @code{comment-start} has the value
1005 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}. 1014 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}.
1006 1015
1007 @vindex comment-padding 1016 @vindex comment-padding
1008 The variable @code{comment-padding} specifies how many spaces 1017 The variable @code{comment-padding} specifies how many spaces
1009 @code{comment-region} should insert on each line between the 1018 @code{comment-region} should insert on each line between the comment
1010 comment delimiter and the line's original text. The default is 1, 1019 delimiter and the line's original text. The default is 1, to insert
1011 to insert one space. 1020 one space. @code{nil} means 0. Alternatively, @code{comment-padding}
1021 can hold the actual string to insert.
1012 1022
1013 @vindex comment-multi-line 1023 @vindex comment-multi-line
1014 The variable @code{comment-multi-line} controls how @kbd{C-M-j} 1024 The variable @code{comment-multi-line} controls how @kbd{C-M-j}
1015 (@code{indent-new-comment-line}) behaves when used inside a comment. If 1025 (@code{indent-new-comment-line}) behaves when used inside a comment.
1016 @code{comment-multi-line} is @code{nil}, as it normally is, then the 1026 Specifically, when @code{comment-multi-line} is @code{nil} (the
1017 comment on the starting line is terminated and a new comment is started 1027 default value), the command inserts a comment terminator, begins a new
1018 on the new following line. If @code{comment-multi-line} is not 1028 line, and finally inserts a comment starter. Otherwise it does not
1019 @code{nil}, then the new following line is set up as part of the same 1029 insert the terminator and starter, so it effectively continues the
1020 comment that was found on the starting line. This is done by not 1030 current comment across multiple lines. In languages that allow
1021 inserting a terminator on the old line, and not inserting a starter on 1031 multi-line comments, the choice of value for this variable is a matter
1022 the new line. In languages where multi-line comments work, the choice 1032 of taste.
1023 of value for this variable is a matter of taste.
1024 1033
1025 @vindex comment-indent-function 1034 @vindex comment-indent-function
1026 The variable @code{comment-indent-function} should contain a function 1035 The variable @code{comment-indent-function} should contain a function
1027 that will be called to compute the indentation for a newly inserted 1036 that will be called to compute the indentation for a newly inserted
1028 comment or for aligning an existing comment. It is set differently by 1037 comment or for aligning an existing comment. It is set differently by
1050 @node Info Lookup 1059 @node Info Lookup
1051 @subsection Info Documentation Lookup 1060 @subsection Info Documentation Lookup
1052 1061
1053 @findex info-lookup-symbol 1062 @findex info-lookup-symbol
1054 @findex info-lookup-file 1063 @findex info-lookup-file
1055 @kindex C-h C-i 1064 @kindex C-h S
1056 For C, Lisp, and other languages that have documentation in Info, 1065 For C, Lisp, and other languages that have documentation in Info,
1057 you can use @kbd{C-h C-i} (@code{info-lookup-symbol}) to view the Info 1066 you can use @kbd{C-h S} (@code{info-lookup-symbol}) to view the Info
1058 documentation for a symbol. You specify the symbol with the 1067 documentation for a symbol. You specify the symbol with the
1059 minibuffer; the default is the symbol appearing in the buffer at 1068 minibuffer; the default is the symbol appearing in the buffer at
1060 point. 1069 point.
1061 1070
1062 The major mode determines where to look for documentation for the 1071 The major mode determines where to look for documentation for the
1063 symbol---which Info files to look in, and which indices to search. 1072 symbol---which Info files to look in, and which indices to search.
1064 You can also use @kbd{M-x info-lookup-file} to look for documentation 1073 You can also use @kbd{M-x info-lookup-file} to look for documentation
1065 for a file name. 1074 for a file name.
1066 1075
1067 This feature currently supports the modes Awk, Autoconf, Bison, C, 1076 This feature currently supports the modes AWK, Autoconf, Bison, C,
1068 Emacs Lisp, LaTeX, M4, Makefile, Octave, Perl, Scheme, and Texinfo, 1077 Emacs Lisp, LaTeX, M4, Makefile, Octave, Perl, Scheme, and Texinfo,
1069 provided you have installed the relevant Info files, which are 1078 provided you have installed the relevant Info files, which are
1070 typically available with the appropriate GNU package. 1079 typically available with the appropriate GNU package.
1071 1080
1072 @node Man Page 1081 @node Man Page
1079 with Info (@pxref{Misc Help}). This process is not finished, so it is 1088 with Info (@pxref{Misc Help}). This process is not finished, so it is
1080 still useful to read manual pages. 1089 still useful to read manual pages.
1081 1090
1082 @findex manual-entry 1091 @findex manual-entry
1083 You can read the man page for an operating system command, library 1092 You can read the man page for an operating system command, library
1084 function, or system call, with the @kbd{M-x manual-entry} command. It 1093 function, or system call, with the @kbd{M-x man} command. It
1085 runs the @code{man} program to format the man page; if the system 1094 runs the @code{man} program to format the man page; if the system
1086 permits, it runs @code{man} asynchronously, so that you can keep on 1095 permits, it runs @code{man} asynchronously, so that you can keep on
1087 editing while the page is being formatted. (On MS-DOS and MS-Windows 1096 editing while the page is being formatted. (On MS-DOS and MS-Windows
1088 3, you cannot edit while Emacs waits for @code{man} to finish.) The 1097 3, you cannot edit while Emacs waits for @code{man} to finish.) The
1089 result goes in a buffer named @samp{*Man @var{topic}*}. These buffers 1098 result goes in a buffer named @samp{*Man @var{topic}*}. These buffers
1391 @cindex Pike mode 1400 @cindex Pike mode
1392 @cindex IDL mode 1401 @cindex IDL mode
1393 @cindex CORBA IDL mode 1402 @cindex CORBA IDL mode
1394 @cindex Objective C mode 1403 @cindex Objective C mode
1395 @cindex C++ mode 1404 @cindex C++ mode
1405 @cindex AWK mode
1396 @cindex mode, Java 1406 @cindex mode, Java
1397 @cindex mode, C 1407 @cindex mode, C
1408 @cindex mode, C++
1398 @cindex mode, Objective C 1409 @cindex mode, Objective C
1399 @cindex mode, CORBA IDL 1410 @cindex mode, CORBA IDL
1400 @cindex mode, Pike 1411 @cindex mode, Pike
1412 @cindex mode, AWK
1401 1413
1402 This section gives a brief description of the special features 1414 This section gives a brief description of the special features
1403 available in C, C++, Objective-C, Java, CORBA IDL, and Pike modes. 1415 available in C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes.
1404 (These are called ``C mode and related modes.'') @xref{Top, , CC Mode, 1416 (These are called ``C mode and related modes.'') @xref{Top, , CC Mode,
1405 ccmode, CC Mode}, for a more extensive description of these modes 1417 ccmode, CC Mode}, for a more extensive description of these modes
1406 and their special features. 1418 and their special features.
1407 1419
1408 @menu 1420 @menu
1409 * Motion in C:: Commands to move by C statements, etc. 1421 * Motion in C:: Commands to move by C statements, etc.
1410 * Electric C:: Colon and other chars can automatically reindent. 1422 * Electric C:: Colon and other chars can automatically reindent.
1411 * Hungry Delete:: A more powerful DEL command. 1423 * Hungry Delete:: A more powerful DEL command.
1412 * Other C Commands:: Filling comments, viewing expansion of macros, 1424 * Other C Commands:: Filling comments, viewing expansion of macros,
1413 and other neat features. 1425 and other neat features.
1414 * Comments in C:: Options for customizing comment style.
1415 @end menu 1426 @end menu
1416 1427
1417 @node Motion in C 1428 @node Motion in C
1418 @subsection C Mode Motion Commands 1429 @subsection C Mode Motion Commands
1419 1430
1420 This section describes commands for moving point, in C mode and 1431 This section describes commands for moving point, in C mode and
1421 related modes. 1432 related modes.
1422 1433
1423 @table @code 1434 @table @code
1435 @item M-x c-beginning-of-defun
1436 @itemx M-x c-end-of-defun
1437 @findex c-beginning-of-defun
1438 @findex c-end-of-defun
1439 Move point to the beginning or end of the current function or
1440 top-level definition. These are found by searching for the least
1441 enclosing braces. (By contrast, @code{beginning-of-defun} and
1442 @code{end-of-defun} search for braces in column zero.) If you are
1443 editing code where the opening brace of a function isn't placed in
1444 column zero, you may wish to bind @code{C-M-a} and @code{C-M-e} to
1445 these commands. @xref{Moving by Defuns}.
1446
1424 @item C-c C-u 1447 @item C-c C-u
1425 @kindex C-c C-u @r{(C mode)} 1448 @kindex C-c C-u @r{(C mode)}
1426 @findex c-up-conditional 1449 @findex c-up-conditional
1427 Move point back to the containing preprocessor conditional, leaving the 1450 Move point back to the containing preprocessor conditional, leaving the
1428 mark behind. A prefix argument acts as a repeat count. With a negative 1451 mark behind. A prefix argument acts as a repeat count. With a negative
1429 argument, move point forward to the end of the containing 1452 argument, move point forward to the end of the containing
1430 preprocessor conditional. When going backwards, @code{#elif} is treated 1453 preprocessor conditional.
1431 like @code{#else} followed by @code{#if}. When going forwards, 1454
1432 @code{#elif} is ignored.@refill 1455 @samp{#elif} is equivalent to @samp{#else} followed by @samp{#if}, so
1456 the function will stop at a @samp{#elif} when going backward, but not
1457 when going forward.
1433 1458
1434 @item C-c C-p 1459 @item C-c C-p
1435 @kindex C-c C-p @r{(C mode)} 1460 @kindex C-c C-p @r{(C mode)}
1436 @findex c-backward-conditional 1461 @findex c-backward-conditional
1437 Move point back over a preprocessor conditional, leaving the mark 1462 Move point back over a preprocessor conditional, leaving the mark
1444 Move point forward across a preprocessor conditional, leaving the mark 1469 Move point forward across a preprocessor conditional, leaving the mark
1445 behind. A prefix argument acts as a repeat count. With a negative 1470 behind. A prefix argument acts as a repeat count. With a negative
1446 argument, move backward. 1471 argument, move backward.
1447 1472
1448 @item M-a 1473 @item M-a
1449 @kindex ESC a 1474 @kindex M-a (C mode)
1450 @findex c-beginning-of-statement 1475 @findex c-beginning-of-statement
1451 Move point to the beginning of the innermost C statement 1476 Move point to the beginning of the innermost C statement
1452 (@code{c-beginning-of-statement}). If point is already at the beginning 1477 (@code{c-beginning-of-statement}). If point is already at the beginning
1453 of a statement, move to the beginning of the preceding statement. With 1478 of a statement, move to the beginning of the preceding statement. With
1454 prefix argument @var{n}, move back @var{n} @minus{} 1 statements. 1479 prefix argument @var{n}, move back @var{n} @minus{} 1 statements.
1455 1480
1456 If point is within a string or comment, or next to a comment (only 1481 In comments or in strings which span more than one line, this command
1457 whitespace between them), this command moves by sentences instead of 1482 moves by sentences instead of statements.
1458 statements.
1459
1460 When called from a program, this function takes three optional
1461 arguments: the numeric prefix argument, a buffer position limit
1462 (don't move back before that place), and a flag that controls whether
1463 to do sentence motion when inside of a comment.
1464 1483
1465 @item M-e 1484 @item M-e
1466 @kindex ESC e 1485 @kindex M-e (C mode)
1467 @findex c-end-of-statement 1486 @findex c-end-of-statement
1468 Move point to the end of the innermost C statement; like @kbd{M-a} 1487 Move point to the end of the innermost C statement or sentence; like
1469 except that it moves in the other direction (@code{c-end-of-statement}). 1488 @kbd{M-a} except that it moves in the other direction
1489 (@code{c-end-of-statement}).
1470 1490
1471 @item M-x c-backward-into-nomenclature 1491 @item M-x c-backward-into-nomenclature
1472 @findex c-backward-into-nomenclature 1492 @findex c-backward-into-nomenclature
1473 Move point backward to beginning of a C++ nomenclature section or word. 1493 Move point backward to beginning of a C++ nomenclature section or word.
1474 With prefix argument @var{n}, move @var{n} times. If @var{n} is 1494 With prefix argument @var{n}, move @var{n} times. If @var{n} is
1528 @findex c-scope-operator 1548 @findex c-scope-operator
1529 Insert a double colon scope operator at point, without reindenting the 1549 Insert a double colon scope operator at point, without reindenting the
1530 line or adding any newlines (@code{c-scope-operator}). 1550 line or adding any newlines (@code{c-scope-operator}).
1531 @end table 1551 @end table
1532 1552
1553 @vindex c-electric-pound-behavior
1533 The electric @kbd{#} key reindents the line if it appears to be the 1554 The electric @kbd{#} key reindents the line if it appears to be the
1534 beginning of a preprocessor directive. This happens when the value of 1555 beginning of a preprocessor directive. This happens when the value of
1535 @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn 1556 @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn
1536 this feature off by setting @code{c-electric-pound-behavior} to 1557 this feature off by setting @code{c-electric-pound-behavior} to
1537 @code{nil}. 1558 @code{nil}.
1538 1559
1560 @vindex c-hanging-braces-alist
1539 The variable @code{c-hanging-braces-alist} controls the insertion of 1561 The variable @code{c-hanging-braces-alist} controls the insertion of
1540 newlines before and after inserted braces. It is an association list 1562 newlines before and after inserted braces. It is an association list
1541 with elements of the following form: @code{(@var{syntactic-symbol} 1563 with elements of the following form: @code{(@var{syntactic-symbol}
1542 . @var{nl-list})}. Most of the syntactic symbols that appear in 1564 . @var{nl-list})}. Most of the syntactic symbols that appear in
1543 @code{c-offsets-alist} are meaningful here as well. 1565 @code{c-offsets-alist} are meaningful here as well.
1548 @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used 1570 @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used
1549 to determine where newlines are inserted: either before the brace, 1571 to determine where newlines are inserted: either before the brace,
1550 after, or both. If not found, the default is to insert a newline both 1572 after, or both. If not found, the default is to insert a newline both
1551 before and after braces. 1573 before and after braces.
1552 1574
1575 @vindex c-hanging-colons-alist
1553 The variable @code{c-hanging-colons-alist} controls the insertion of 1576 The variable @code{c-hanging-colons-alist} controls the insertion of
1554 newlines before and after inserted colons. It is an association list 1577 newlines before and after inserted colons. It is an association list
1555 with elements of the following form: @code{(@var{syntactic-symbol} 1578 with elements of the following form: @code{(@var{syntactic-symbol}
1556 . @var{nl-list})}. The list @var{nl-list} may contain either of the 1579 . @var{nl-list})}. The list @var{nl-list} may contain either of the
1557 symbols @code{before} or @code{after}, or both; or it may be @code{nil}. 1580 symbols @code{before} or @code{after}, or both; or it may be @code{nil}.
1560 up in this list, and if found, the @var{nl-list} is used to determine 1583 up in this list, and if found, the @var{nl-list} is used to determine
1561 where newlines are inserted: either before the brace, after, or both. 1584 where newlines are inserted: either before the brace, after, or both.
1562 If the syntactic symbol is not found in this list, no newlines are 1585 If the syntactic symbol is not found in this list, no newlines are
1563 inserted. 1586 inserted.
1564 1587
1588 @vindex c-cleanup-list
1565 Electric characters can also delete newlines automatically when the 1589 Electric characters can also delete newlines automatically when the
1566 auto-newline feature is enabled. This feature makes auto-newline more 1590 auto-newline feature is enabled. This feature makes auto-newline more
1567 acceptable, by deleting the newlines in the most common cases where you 1591 acceptable, by deleting the newlines in the most common cases where you
1568 do not want them. Emacs can recognize several cases in which deleting a 1592 do not want them. Emacs can recognize several cases in which deleting a
1569 newline might be desirable; by setting the variable 1593 newline might be desirable; by setting the variable
1611 whitespace. 1635 whitespace.
1612 @end table 1636 @end table
1613 1637
1614 @node Hungry Delete 1638 @node Hungry Delete
1615 @subsection Hungry Delete Feature in C 1639 @subsection Hungry Delete Feature in C
1640 @cindex hungry deletion (C Mode)
1616 1641
1617 When the @dfn{hungry-delete} feature is enabled (indicated by 1642 When the @dfn{hungry-delete} feature is enabled (indicated by
1618 @samp{/h} or @samp{/ah} in the mode line after the mode name), a single 1643 @samp{/h} or @samp{/ah} in the mode line after the mode name), a single
1619 @key{DEL} command deletes all preceding whitespace, not just one space. 1644 @key{DEL} command deletes all preceding whitespace, not just one space.
1620 To turn this feature on or off, use @kbd{C-c C-d}: 1645 To turn this feature on or off, use @kbd{C-c C-d}:
1640 1665
1641 @node Other C Commands 1666 @node Other C Commands
1642 @subsection Other Commands for C Mode 1667 @subsection Other Commands for C Mode
1643 1668
1644 @table @kbd 1669 @table @kbd
1670 @item M-x c-context-line-break
1671 @findex c-context-line-break
1672 This command inserts a line break and indents the new line in a manner
1673 appropriate to the context. In normal code, it does the work of
1674 @kbd{C-j} (@code{newline-and-indent}), in a C preprocessor line it
1675 additionally inserts a @samp{\} at the line break, and within comments
1676 it's like @kbd{M-j} (@code{c-indent-new-comment-line}).
1677
1678 @code{c-context-line-break} isn't bound to a key by default, but it
1679 needs a binding to be useful. The following code will bind it to
1680 @kbd{C-j}.
1681 @example
1682 (define-key c-mode-base-map "\C-j" 'c-context-line-break)
1683 @end example
1684
1645 @item C-M-h 1685 @item C-M-h
1646 Put mark at the end of a function definition, and put point at the 1686 Put mark at the end of a function definition, and put point at the
1647 beginning (@code{c-mark-function}). 1687 beginning (@code{c-mark-function}).
1648 1688
1649 @item M-q 1689 @item M-q
1700 1740
1701 @item M-x cwarn-mode 1741 @item M-x cwarn-mode
1702 @itemx M-x global-cwarn-mode 1742 @itemx M-x global-cwarn-mode
1703 @findex cwarn-mode 1743 @findex cwarn-mode
1704 @findex global-cwarn-mode 1744 @findex global-cwarn-mode
1745 @vindex global-cwarn-mode
1705 @cindex CWarn mode 1746 @cindex CWarn mode
1706 @cindex suspicious constructions in C, C++ 1747 @cindex suspicious constructions in C, C++
1707 CWarn minor mode highlights certain suspicious C and C++ constructions: 1748 CWarn minor mode highlights certain suspicious C and C++ constructions:
1708 1749
1709 @itemize @bullet{} 1750 @itemize @bullet{}
1737 Find a file ``related'' in a special way to the file visited by the 1778 Find a file ``related'' in a special way to the file visited by the
1738 current buffer. Typically this will be the header file corresponding 1779 current buffer. Typically this will be the header file corresponding
1739 to a C/C++ source file, or vice versa. The variable 1780 to a C/C++ source file, or vice versa. The variable
1740 @code{ff-related-file-alist} specifies how to compute related file 1781 @code{ff-related-file-alist} specifies how to compute related file
1741 names. 1782 names.
1742 @end table
1743
1744 @node Comments in C
1745 @subsection Comments in C Modes
1746
1747 C mode and related modes use a number of variables for controlling
1748 comment format.
1749
1750 @table @code
1751 @item c-comment-only-line-offset
1752 @vindex c-comment-only-line-offset
1753 Extra offset for line which contains only the start of a comment. It
1754 can be either an integer or a cons cell of the form
1755 @code{(@var{non-anchored-offset} . @var{anchored-offset})}, where
1756 @var{non-anchored-offset} is the amount of offset given to
1757 non-column-zero anchored comment-only lines, and @var{anchored-offset}
1758 is the amount of offset to give column-zero anchored comment-only lines.
1759 Just an integer as value is equivalent to @code{(@var{val} . 0)}.
1760
1761 @item c-comment-start-regexp
1762 @vindex c-comment-start-regexp
1763 This buffer-local variable specifies how to recognize the start of a comment.
1764
1765 @item c-hanging-comment-ender-p
1766 @vindex c-hanging-comment-ender-p
1767 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
1768 comment terminator of a block comment on a line by itself. The default
1769 value is @code{t}, which puts the comment-end delimiter @samp{*/} at the
1770 end of the last line of the comment text.
1771
1772 @item c-hanging-comment-starter-p
1773 @vindex c-hanging-comment-starter-p
1774 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the
1775 starting delimiter of a block comment on a line by itself. The default
1776 value is @code{t}, which puts the comment-start delimiter @samp{/*} at
1777 the beginning of the first line of the comment text.
1778 @end table 1783 @end table
1779 1784
1780 @node Fortran 1785 @node Fortran
1781 @section Fortran Mode 1786 @section Fortran Mode
1782 @cindex Fortran mode 1787 @cindex Fortran mode