diff options
| author | Richard M. Stallman | 2004-06-13 22:14:41 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-06-13 22:14:41 +0000 |
| commit | 7ae8ad948e6135155bcfe54a41e09e1eafa1414d (patch) | |
| tree | a5b0720727c3a04e6140484c25a967c00da05164 | |
| parent | a67091f2b3b3cca4320852c90fb0b72f7f1ff02f (diff) | |
| download | emacs-7ae8ad948e6135155bcfe54a41e09e1eafa1414d.tar.gz emacs-7ae8ad948e6135155bcfe54a41e09e1eafa1414d.zip | |
Update for CC Mode 5.30 and incidental amendments.
("AWK"): Is consistently thus spelt throughout.
(AWK, Pike): Document as "C-like modes".
(@kbd{M-j}): Document as alternative to @kbd{C-M-j}.
(M-x man): Supersedes M-x manual-entry.
Add numerous index entries. Correct "ESC a/e" to "M-a/e".
("Comments in C"): Delete node; the info is in CC Mode manual.
(c-comment-only-line-offset): Remove description.
(C-c ., C-c C-c): Describe new C Mode bindings.
(C-u TAB, indent-code-rigidly, c-indent-exp, c-tab-always-indent)
(@dfn{Style}, c-default-style, comment-column, comment-padding)
(c-up-conditional, c-beginning-of-statement, c-end-of-statement):
Amend definitions.
(c-beginning-of-defun, c-end-of-defun, c-context-line-break):
Describe functions.
(c-comment-start-regexp, c-hanging-comment-ender-p)
(c-hanging-comment-starter-p): Remove obsolete definitions.
| -rw-r--r-- | man/programs.texi | 245 |
1 files changed, 125 insertions, 120 deletions
diff --git a/man/programs.texi b/man/programs.texi index 84f3e6f14f8..9c081a7315b 100644 --- a/man/programs.texi +++ b/man/programs.texi | |||
| @@ -65,7 +65,6 @@ and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}. | |||
| 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 |
| @@ -82,7 +81,7 @@ and you can select it by typing @kbd{M-x @var{l}-mode @key{RET}}. | |||
| 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 |
| @@ -104,7 +103,7 @@ 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 | ||
| @@ -446,15 +445,16 @@ 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 |
| @@ -507,14 +507,15 @@ declaration (@code{c-indent-defun}). | |||
| 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 | ||
| @@ -524,8 +525,7 @@ 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 |
| @@ -539,18 +539,19 @@ to the front of the block and then reindents it all. | |||
| 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}, |
| @@ -561,19 +562,21 @@ 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 |
| @@ -848,18 +851,20 @@ also do spell checking on comments with Flyspell Prog mode | |||
| 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 | ||
| @@ -937,17 +942,20 @@ is indented like a line of code. | |||
| 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 |
| @@ -970,12 +978,13 @@ if within a defun, it must be three. | |||
| 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 |
| @@ -990,7 +999,7 @@ 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 |
| @@ -1006,21 +1015,21 @@ into the comment. In C mode, @code{comment-start} has the value | |||
| 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 |
| @@ -1064,7 +1073,7 @@ 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. |
| @@ -1081,7 +1090,7 @@ 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 |
| @@ -1393,25 +1402,27 @@ Mode}). The Foldout package provides folding-editor features | |||
| 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 |
| @@ -1421,15 +1432,29 @@ and their special features. | |||
| 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)} |
| @@ -1446,27 +1471,22 @@ 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 |
| @@ -1530,12 +1550,14 @@ 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} |
| @@ -1550,6 +1572,7 @@ 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} |
| @@ -1562,6 +1585,7 @@ 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 |
| @@ -1613,6 +1637,7 @@ whitespace. | |||
| 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 |
| @@ -1642,6 +1667,21 @@ hungry-delete feature is enabled. | |||
| 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}). |
| @@ -1702,6 +1742,7 @@ directs how the line is indented. | |||
| 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: |
| @@ -1741,42 +1782,6 @@ to a C/C++ source file, or vice versa. The variable | |||
| 1741 | names. | 1782 | names. |
| 1742 | @end table | 1783 | @end table |
| 1743 | 1784 | ||
| 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 | ||
| 1779 | |||
| 1780 | @node Fortran | 1785 | @node Fortran |
| 1781 | @section Fortran Mode | 1786 | @section Fortran Mode |
| 1782 | @cindex Fortran mode | 1787 | @cindex Fortran mode |