65 |
|
|
66 |
@cindex Perl mode |
@cindex Perl mode |
67 |
@cindex Icon mode |
@cindex Icon mode |
|
@cindex Awk mode |
|
68 |
@cindex Makefile mode |
@cindex Makefile mode |
69 |
@cindex Tcl mode |
@cindex Tcl mode |
70 |
@cindex CPerl mode |
@cindex CPerl mode |
81 |
@cindex PostScript mode |
@cindex PostScript mode |
82 |
The existing programming language major modes include Lisp, Scheme (a |
The existing programming language major modes include Lisp, Scheme (a |
83 |
variant of Lisp) and the Scheme-based DSSSL expression language, Ada, |
variant of Lisp) and the Scheme-based DSSSL expression language, Ada, |
84 |
Awk, C, C++, Delphi (Object Pascal), Fortran (free format and fixed |
AWK, C, C++, Delphi (Object Pascal), Fortran (free format and fixed |
85 |
format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s |
format), Icon, IDL (CORBA), IDLWAVE, Java, Metafont (@TeX{}'s |
86 |
companion for font creation), Modula2, Objective-C, Octave, Pascal, |
companion for font creation), Modula2, Objective-C, Octave, Pascal, |
87 |
Perl, Pike, PostScript, Prolog, Simula, Tcl, and VHDL. There is |
Perl, Pike, PostScript, Prolog, Simula, Tcl, and VHDL. There is |
103 |
tab character before point, in these modes. |
tab character before point, in these modes. |
104 |
|
|
105 |
Separate manuals are available for the modes for Ada (@pxref{Top, , Ada |
Separate manuals are available for the modes for Ada (@pxref{Top, , Ada |
106 |
Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL |
Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL/Pike/AWK |
107 |
(@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes |
(@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes |
108 |
(@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). |
(@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). |
109 |
|
|
445 |
reindents the current line as usual, then reindents by the same amount |
reindents the current line as usual, then reindents by the same amount |
446 |
all the lines in the parenthetical grouping starting on the current |
all the lines in the parenthetical grouping starting on the current |
447 |
line. It is clever, though, and does not alter lines that start |
line. It is clever, though, and does not alter lines that start |
448 |
inside strings, or C preprocessor lines when in C mode. |
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. |
451 |
|
|
452 |
@findex indent-code-rigidly |
@findex indent-code-rigidly |
453 |
You can also perform this operation on the region, using the command |
You can also perform this operation on the region, using the command |
454 |
@kbd{M-x indent-code-rigidly}. It rigidly shifts all the lines in the |
@kbd{M-x indent-code-rigidly}. It rigidly shifts all the lines in the |
455 |
region sideways, like @code{indent-rigidly} does (@pxref{Indentation |
region sideways, like @code{indent-rigidly} does (@pxref{Indentation |
456 |
Commands}). It doesn't alter the indentation of lines that start |
Commands}). It doesn't alter the indentation of lines that start |
457 |
inside a comment or a string, unless the region starts inside that |
inside a string, unless the region also starts inside that string. |
|
comment or string. |
|
458 |
|
|
459 |
@node Lisp Indent |
@node Lisp Indent |
460 |
@subsection Customizing Lisp Indentation |
@subsection Customizing Lisp Indentation |
507 |
@kindex C-M-q @r{(C mode)} |
@kindex C-M-q @r{(C mode)} |
508 |
@findex c-indent-exp |
@findex c-indent-exp |
509 |
Reindent each line in the balanced expression that follows point |
Reindent each line in the balanced expression that follows point |
510 |
(@code{c-indent-exp}). A prefix argument inhibits error checking and |
(@code{c-indent-exp}). A prefix argument inhibits warning messages |
511 |
warning messages about invalid syntax. |
about invalid syntax. |
512 |
|
|
513 |
@item @key{TAB} |
@item @key{TAB} |
514 |
@findex c-indent-command |
@findex c-indent-command |
515 |
Reindent the current line, and/or in some cases insert a tab character |
Reindent the current line, and/or in some cases insert a tab character |
516 |
(@code{c-indent-command}). |
(@code{c-indent-command}). |
517 |
|
|
518 |
|
@vindex c-tab-always-indent |
519 |
If @code{c-tab-always-indent} is @code{t}, this command always reindents |
If @code{c-tab-always-indent} is @code{t}, this command always reindents |
520 |
the current line and does nothing else. This is the default. |
the current line and does nothing else. This is the default. |
521 |
|
|
525 |
if @code{indent-tabs-mode} is @code{nil}). |
if @code{indent-tabs-mode} is @code{nil}). |
526 |
|
|
527 |
Any other value (not @code{nil} or @code{t}) means always reindent the |
Any other value (not @code{nil} or @code{t}) means always reindent the |
528 |
line, and also insert a tab if within a comment, a string, or a |
line, and also insert a tab if within a comment or a string. |
|
preprocessor directive. |
|
529 |
@end table |
@end table |
530 |
|
|
531 |
To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This |
To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This |
539 |
@subsection Customizing C Indentation |
@subsection Customizing C Indentation |
540 |
@cindex style (for indentation) |
@cindex style (for indentation) |
541 |
|
|
542 |
C mode and related modes use a simple yet flexible mechanism for |
C mode and related modes use a flexible mechanism for customizing |
543 |
customizing indentation. The mechanism works in two steps: first it |
indentation. C mode indents a source line in two steps: first it |
544 |
classifies the line syntactically according to its contents and context; |
classifies the line syntactically according to its contents and |
545 |
second, it associates each kind of syntactic construct with an |
context; second, it determines the indentation offset associated by |
546 |
indentation offset based on your selected @dfn{style}. |
your selected @dfn{style} with the syntactic construct and adds this |
547 |
|
onto the indentation of the @dfn{anchor statement}. |
548 |
|
|
549 |
@table @kbd |
@table @kbd |
550 |
@item M-x c-set-style @key{RET} @var{style} @key{RET} |
@item C-c . @key{RET} @var{style} @key{RET} |
551 |
Select predefined indentation style @var{style}. |
Select a predefined style @var{style} (@code{c-set-style}). |
552 |
@end table |
@end table |
553 |
|
|
554 |
A style is a named collection of indentation customizations that can |
A @dfn{style} is a named collection of customizations that can |
555 |
be used in C mode and the related modes. Emacs comes with several |
be used in C mode and the related modes. Emacs comes with several |
556 |
predefined styles, including @code{gnu}, @code{k&r}, @code{bsd}, |
predefined styles, including @code{gnu}, @code{k&r}, @code{bsd}, |
557 |
@code{stroustrup}, @code{linux}, @code{python}, @code{java}, |
@code{stroustrup}, @code{linux}, @code{python}, @code{java}, |
562 |
some code, e.g., by typing @key{C-M-q} at the start of a function |
some code, e.g., by typing @key{C-M-q} at the start of a function |
563 |
definition. |
definition. |
564 |
|
|
565 |
|
@kindex C-c . @r{(C mode)} |
566 |
@findex c-set-style |
@findex c-set-style |
567 |
To choose a style for the current buffer, use the command @kbd{M-x |
To choose a style for the current buffer, use the command @kbd{C-c |
568 |
c-set-style}. Specify a style name as an argument (case is not |
.}. Specify a style name as an argument (case is not significant). |
569 |
significant). This command affects the current buffer only, and it |
This command affects the current buffer only, and it affects only |
570 |
affects only future invocations of the indentation commands; it does |
future invocations of the indentation commands; it does not reindent |
571 |
not reindent the code in the buffer. To reindent the whole buffer in |
the code in the buffer. To reindent the whole buffer in the new |
572 |
the new style, you can type @kbd{C-x h C-M-\}. |
style, you can type @kbd{C-x h C-M-\}. |
573 |
|
|
574 |
@vindex c-default-style |
@vindex c-default-style |
575 |
You can also set the variable @code{c-default-style} to specify the |
You can also set the variable @code{c-default-style} to specify the |
576 |
default style for various major modes. Its value should be an alist, |
default style for various major modes. Its value should be either the |
577 |
in which each element specifies one major mode and which indentation |
style's name (a string) or an alist, in which each element specifies |
578 |
style to use for it. For example, |
one major mode and which indentation style to use for it. For |
579 |
|
example, |
580 |
|
|
581 |
@example |
@example |
582 |
(setq c-default-style |
(setq c-default-style |
851 |
The comment commands in this table insert, kill and align comments. |
The comment commands in this table insert, kill and align comments. |
852 |
They are described in this section and following sections. |
They are described in this section and following sections. |
853 |
|
|
854 |
@table @kbd |
@table @asis |
855 |
@item M-; |
@item @kbd{M-;} |
856 |
Insert or realign comment on current line; alternatively, comment or |
Insert or realign comment on current line; alternatively, comment or |
857 |
uncomment the region (@code{comment-dwim}). |
uncomment the region (@code{comment-dwim}). |
858 |
@item C-u M-; |
@item @kbd{C-u M-;} |
859 |
Kill comment on current line (@code{comment-kill}). |
Kill comment on current line (@code{comment-kill}). |
860 |
@item C-x ; |
@item @kbd{C-x ;} |
861 |
Set comment column (@code{comment-set-column}). |
Set comment column (@code{comment-set-column}). |
862 |
@item C-M-j |
@item @kbd{C-M-j} |
863 |
|
@itemx @kbd{M-j} |
864 |
Like @key{RET} followed by inserting and aligning a comment |
Like @key{RET} followed by inserting and aligning a comment |
865 |
(@code{comment-indent-new-line}). |
(@code{comment-indent-new-line}). |
866 |
@item M-x comment-region |
@item @kbd{M-x comment-region} |
867 |
|
@itemx @kbd{C-c C-c} (in C-like modes) |
868 |
Add or remove comment delimiters on all the lines in the region. |
Add or remove comment delimiters on all the lines in the region. |
869 |
@end table |
@end table |
870 |
|
|
942 |
@subsection Multiple Lines of Comments |
@subsection Multiple Lines of Comments |
943 |
|
|
944 |
@kindex C-M-j |
@kindex C-M-j |
945 |
|
@kindex M-j |
946 |
@cindex blank lines in programs |
@cindex blank lines in programs |
947 |
@findex comment-indent-new-line |
@findex comment-indent-new-line |
948 |
If you are typing a comment and wish to continue it on another line, |
If you are typing a comment and wish to continue it on another line, |
949 |
you can use the command @kbd{C-M-j} (@code{comment-indent-new-line}). |
you can use the command @kbd{C-M-j} or @kbd{M-j} |
950 |
This terminates the comment you are typing, creates a new blank line |
(@code{comment-indent-new-line}). This terminates the comment you are |
951 |
afterward, and begins a new comment indented under the old one. When |
typing, creates a new blank line afterward, and begins a new comment |
952 |
Auto Fill mode is on, going past the fill column while typing a comment |
indented under the old one. When Auto Fill mode is on, going past the |
953 |
causes the comment to be continued in just this fashion. If point is |
fill column while typing a comment causes the comment to be continued |
954 |
not at the end of the line when @kbd{C-M-j} is typed, the text on |
in just this fashion. If point is not at the end of the line when you |
955 |
the rest of the line becomes part of the new comment line. |
type the command, the text on the rest of the line becomes part of the |
956 |
|
new comment line. |
957 |
|
|
958 |
|
@kindex C-c C-c (C mode) |
959 |
@findex comment-region |
@findex comment-region |
960 |
To turn existing lines into comment lines, use the @kbd{M-x |
To turn existing lines into comment lines, use the @kbd{M-x |
961 |
comment-region} command. It adds comment delimiters to the lines that start |
comment-region} command. It adds comment delimiters to the lines that start |
978 |
@vindex comment-column |
@vindex comment-column |
979 |
@kindex C-x ; |
@kindex C-x ; |
980 |
@findex comment-set-column |
@findex comment-set-column |
981 |
The comment column is stored in the variable @code{comment-column}. You |
The @dfn{comment column}, the column at which Emacs tries to place |
982 |
can set it to a number explicitly. Alternatively, the command @kbd{C-x ;} |
comments, is stored in the variable @code{comment-column}. You can |
983 |
(@code{comment-set-column}) sets the comment column to the column point is |
set it to a number explicitly. Alternatively, the command @kbd{C-x ;} |
984 |
at. @kbd{C-u C-x ;} sets the comment column to match the last comment |
(@code{comment-set-column}) sets the comment column to the column |
985 |
before point in the buffer, and then does a @kbd{M-;} to align the |
point is at. @kbd{C-u C-x ;} sets the comment column to match the |
986 |
current line's comment under the previous one. |
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. |
988 |
|
|
989 |
The variable @code{comment-column} is per-buffer: setting the variable |
The variable @code{comment-column} is per-buffer: setting the variable |
990 |
in the normal fashion affects only the current buffer, but there is a |
in the normal fashion affects only the current buffer, but there is a |
999 |
than the comment starting delimiter in the strictest sense of the word; |
than the comment starting delimiter in the strictest sense of the word; |
1000 |
for example, in C mode the value of the variable is |
for example, in C mode the value of the variable is |
1001 |
@c This stops M-q from breaking the line inside that @code. |
@c This stops M-q from breaking the line inside that @code. |
1002 |
@code{@w{"/\\*+ *\\|//+ *""}}, which matches extra stars and spaces |
@code{@w{"/\\*+ *\\|//+ *"}}, which matches extra stars and spaces |
1003 |
after the @samp{/*} itself, and accepts C++ style comments also. |
after the @samp{/*} itself, and accepts C++ style comments also. |
1004 |
(Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in |
(Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in |
1005 |
the string, which is needed to deny the first star its special meaning |
the string, which is needed to deny the first star its special meaning |
1015 |
|
|
1016 |
@vindex comment-padding |
@vindex comment-padding |
1017 |
The variable @code{comment-padding} specifies how many spaces |
The variable @code{comment-padding} specifies how many spaces |
1018 |
@code{comment-region} should insert on each line between the |
@code{comment-region} should insert on each line between the comment |
1019 |
comment delimiter and the line's original text. The default is 1, |
delimiter and the line's original text. The default is 1, to insert |
1020 |
to insert one space. |
one space. @code{nil} means 0. Alternatively, @code{comment-padding} |
1021 |
|
can hold the actual string to insert. |
1022 |
|
|
1023 |
@vindex comment-multi-line |
@vindex comment-multi-line |
1024 |
The variable @code{comment-multi-line} controls how @kbd{C-M-j} |
The variable @code{comment-multi-line} controls how @kbd{C-M-j} |
1025 |
(@code{indent-new-comment-line}) behaves when used inside a comment. If |
(@code{indent-new-comment-line}) behaves when used inside a comment. |
1026 |
@code{comment-multi-line} is @code{nil}, as it normally is, then the |
Specifically, when @code{comment-multi-line} is @code{nil} (the |
1027 |
comment on the starting line is terminated and a new comment is started |
default value), the command inserts a comment terminator, begins a new |
1028 |
on the new following line. If @code{comment-multi-line} is not |
line, and finally inserts a comment starter. Otherwise it does not |
1029 |
@code{nil}, then the new following line is set up as part of the same |
insert the terminator and starter, so it effectively continues the |
1030 |
comment that was found on the starting line. This is done by not |
current comment across multiple lines. In languages that allow |
1031 |
inserting a terminator on the old line, and not inserting a starter on |
multi-line comments, the choice of value for this variable is a matter |
1032 |
the new line. In languages where multi-line comments work, the choice |
of taste. |
|
of value for this variable is a matter of taste. |
|
1033 |
|
|
1034 |
@vindex comment-indent-function |
@vindex comment-indent-function |
1035 |
The variable @code{comment-indent-function} should contain a function |
The variable @code{comment-indent-function} should contain a function |
1061 |
|
|
1062 |
@findex info-lookup-symbol |
@findex info-lookup-symbol |
1063 |
@findex info-lookup-file |
@findex info-lookup-file |
1064 |
@kindex C-h C-i |
@kindex C-h S |
1065 |
For C, Lisp, and other languages that have documentation in Info, |
For C, Lisp, and other languages that have documentation in Info, |
1066 |
you can use @kbd{C-h C-i} (@code{info-lookup-symbol}) to view the Info |
you can use @kbd{C-h S} (@code{info-lookup-symbol}) to view the Info |
1067 |
documentation for a symbol. You specify the symbol with the |
documentation for a symbol. You specify the symbol with the |
1068 |
minibuffer; the default is the symbol appearing in the buffer at |
minibuffer; the default is the symbol appearing in the buffer at |
1069 |
point. |
point. |
1073 |
You can also use @kbd{M-x info-lookup-file} to look for documentation |
You can also use @kbd{M-x info-lookup-file} to look for documentation |
1074 |
for a file name. |
for a file name. |
1075 |
|
|
1076 |
This feature currently supports the modes Awk, Autoconf, Bison, C, |
This feature currently supports the modes AWK, Autoconf, Bison, C, |
1077 |
Emacs Lisp, LaTeX, M4, Makefile, Octave, Perl, Scheme, and Texinfo, |
Emacs Lisp, LaTeX, M4, Makefile, Octave, Perl, Scheme, and Texinfo, |
1078 |
provided you have installed the relevant Info files, which are |
provided you have installed the relevant Info files, which are |
1079 |
typically available with the appropriate GNU package. |
typically available with the appropriate GNU package. |
1090 |
|
|
1091 |
@findex manual-entry |
@findex manual-entry |
1092 |
You can read the man page for an operating system command, library |
You can read the man page for an operating system command, library |
1093 |
function, or system call, with the @kbd{M-x manual-entry} command. It |
function, or system call, with the @kbd{M-x man} command. It |
1094 |
runs the @code{man} program to format the man page; if the system |
runs the @code{man} program to format the man page; if the system |
1095 |
permits, it runs @code{man} asynchronously, so that you can keep on |
permits, it runs @code{man} asynchronously, so that you can keep on |
1096 |
editing while the page is being formatted. (On MS-DOS and MS-Windows |
editing while the page is being formatted. (On MS-DOS and MS-Windows |
1402 |
@cindex CORBA IDL mode |
@cindex CORBA IDL mode |
1403 |
@cindex Objective C mode |
@cindex Objective C mode |
1404 |
@cindex C++ mode |
@cindex C++ mode |
1405 |
|
@cindex AWK mode |
1406 |
@cindex mode, Java |
@cindex mode, Java |
1407 |
@cindex mode, C |
@cindex mode, C |
1408 |
|
@cindex mode, C++ |
1409 |
@cindex mode, Objective C |
@cindex mode, Objective C |
1410 |
@cindex mode, CORBA IDL |
@cindex mode, CORBA IDL |
1411 |
@cindex mode, Pike |
@cindex mode, Pike |
1412 |
|
@cindex mode, AWK |
1413 |
|
|
1414 |
This section gives a brief description of the special features |
This section gives a brief description of the special features |
1415 |
available in C, C++, Objective-C, Java, CORBA IDL, and Pike modes. |
available in C, C++, Objective-C, Java, CORBA IDL, Pike and AWK modes. |
1416 |
(These are called ``C mode and related modes.'') @xref{Top, , CC Mode, |
(These are called ``C mode and related modes.'') @xref{Top, , CC Mode, |
1417 |
ccmode, CC Mode}, for a more extensive description of these modes |
ccmode, CC Mode}, for a more extensive description of these modes |
1418 |
and their special features. |
and their special features. |
1419 |
|
|
1420 |
@menu |
@menu |
1421 |
* Motion in C:: Commands to move by C statements, etc. |
* Motion in C:: Commands to move by C statements, etc. |
1422 |
* Electric C:: Colon and other chars can automatically reindent. |
* Electric C:: Colon and other chars can automatically reindent. |
1423 |
* Hungry Delete:: A more powerful DEL command. |
* Hungry Delete:: A more powerful DEL command. |
1424 |
* Other C Commands:: Filling comments, viewing expansion of macros, |
* Other C Commands:: Filling comments, viewing expansion of macros, |
1425 |
and other neat features. |
and other neat features. |
|
* Comments in C:: Options for customizing comment style. |
|
1426 |
@end menu |
@end menu |
1427 |
|
|
1428 |
@node Motion in C |
@node Motion in C |
1432 |
related modes. |
related modes. |
1433 |
|
|
1434 |
@table @code |
@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 |
|
|
1447 |
@item C-c C-u |
@item C-c C-u |
1448 |
@kindex C-c C-u @r{(C mode)} |
@kindex C-c C-u @r{(C mode)} |
1449 |
@findex c-up-conditional |
@findex c-up-conditional |
1450 |
Move point back to the containing preprocessor conditional, leaving the |
Move point back to the containing preprocessor conditional, leaving the |
1451 |
mark behind. A prefix argument acts as a repeat count. With a negative |
mark behind. A prefix argument acts as a repeat count. With a negative |
1452 |
argument, move point forward to the end of the containing |
argument, move point forward to the end of the containing |
1453 |
preprocessor conditional. When going backwards, @code{#elif} is treated |
preprocessor conditional. |
1454 |
like @code{#else} followed by @code{#if}. When going forwards, |
|
1455 |
@code{#elif} is ignored.@refill |
@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. |
1458 |
|
|
1459 |
@item C-c C-p |
@item C-c C-p |
1460 |
@kindex C-c C-p @r{(C mode)} |
@kindex C-c C-p @r{(C mode)} |
1471 |
argument, move backward. |
argument, move backward. |
1472 |
|
|
1473 |
@item M-a |
@item M-a |
1474 |
@kindex ESC a |
@kindex M-a (C mode) |
1475 |
@findex c-beginning-of-statement |
@findex c-beginning-of-statement |
1476 |
Move point to the beginning of the innermost C statement |
Move point to the beginning of the innermost C statement |
1477 |
(@code{c-beginning-of-statement}). If point is already at the beginning |
(@code{c-beginning-of-statement}). If point is already at the beginning |
1478 |
of a statement, move to the beginning of the preceding statement. With |
of a statement, move to the beginning of the preceding statement. With |
1479 |
prefix argument @var{n}, move back @var{n} @minus{} 1 statements. |
prefix argument @var{n}, move back @var{n} @minus{} 1 statements. |
1480 |
|
|
1481 |
If point is within a string or comment, or next to a comment (only |
In comments or in strings which span more than one line, this command |
1482 |
whitespace between them), this command moves by sentences instead of |
moves by sentences instead of statements. |
|
statements. |
|
|
|
|
|
When called from a program, this function takes three optional |
|
|
arguments: the numeric prefix argument, a buffer position limit |
|
|
(don't move back before that place), and a flag that controls whether |
|
|
to do sentence motion when inside of a comment. |
|
1483 |
|
|
1484 |
@item M-e |
@item M-e |
1485 |
@kindex ESC e |
@kindex M-e (C mode) |
1486 |
@findex c-end-of-statement |
@findex c-end-of-statement |
1487 |
Move point to the end of the innermost C statement; like @kbd{M-a} |
Move point to the end of the innermost C statement or sentence; like |
1488 |
except that it moves in the other direction (@code{c-end-of-statement}). |
@kbd{M-a} except that it moves in the other direction |
1489 |
|
(@code{c-end-of-statement}). |
1490 |
|
|
1491 |
@item M-x c-backward-into-nomenclature |
@item M-x c-backward-into-nomenclature |
1492 |
@findex c-backward-into-nomenclature |
@findex c-backward-into-nomenclature |
1550 |
line or adding any newlines (@code{c-scope-operator}). |
line or adding any newlines (@code{c-scope-operator}). |
1551 |
@end table |
@end table |
1552 |
|
|
1553 |
|
@vindex c-electric-pound-behavior |
1554 |
The electric @kbd{#} key reindents the line if it appears to be the |
The electric @kbd{#} key reindents the line if it appears to be the |
1555 |
beginning of a preprocessor directive. This happens when the value of |
beginning of a preprocessor directive. This happens when the value of |
1556 |
@code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn |
@code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn |
1557 |
this feature off by setting @code{c-electric-pound-behavior} to |
this feature off by setting @code{c-electric-pound-behavior} to |
1558 |
@code{nil}. |
@code{nil}. |
1559 |
|
|
1560 |
|
@vindex c-hanging-braces-alist |
1561 |
The variable @code{c-hanging-braces-alist} controls the insertion of |
The variable @code{c-hanging-braces-alist} controls the insertion of |
1562 |
newlines before and after inserted braces. It is an association list |
newlines before and after inserted braces. It is an association list |
1563 |
with elements of the following form: @code{(@var{syntactic-symbol} |
with elements of the following form: @code{(@var{syntactic-symbol} |
1572 |
after, or both. If not found, the default is to insert a newline both |
after, or both. If not found, the default is to insert a newline both |
1573 |
before and after braces. |
before and after braces. |
1574 |
|
|
1575 |
|
@vindex c-hanging-colons-alist |
1576 |
The variable @code{c-hanging-colons-alist} controls the insertion of |
The variable @code{c-hanging-colons-alist} controls the insertion of |
1577 |
newlines before and after inserted colons. It is an association list |
newlines before and after inserted colons. It is an association list |
1578 |
with elements of the following form: @code{(@var{syntactic-symbol} |
with elements of the following form: @code{(@var{syntactic-symbol} |
1585 |
If the syntactic symbol is not found in this list, no newlines are |
If the syntactic symbol is not found in this list, no newlines are |
1586 |
inserted. |
inserted. |
1587 |
|
|
1588 |
|
@vindex c-cleanup-list |
1589 |
Electric characters can also delete newlines automatically when the |
Electric characters can also delete newlines automatically when the |
1590 |
auto-newline feature is enabled. This feature makes auto-newline more |
auto-newline feature is enabled. This feature makes auto-newline more |
1591 |
acceptable, by deleting the newlines in the most common cases where you |
acceptable, by deleting the newlines in the most common cases where you |
1637 |
|
|
1638 |
@node Hungry Delete |
@node Hungry Delete |
1639 |
@subsection Hungry Delete Feature in C |
@subsection Hungry Delete Feature in C |
1640 |
|
@cindex hungry deletion (C Mode) |
1641 |
|
|
1642 |
When the @dfn{hungry-delete} feature is enabled (indicated by |
When the @dfn{hungry-delete} feature is enabled (indicated by |
1643 |
@samp{/h} or @samp{/ah} in the mode line after the mode name), a single |
@samp{/h} or @samp{/ah} in the mode line after the mode name), a single |
1667 |
@subsection Other Commands for C Mode |
@subsection Other Commands for C Mode |
1668 |
|
|
1669 |
@table @kbd |
@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 |
|
|
1685 |
@item C-M-h |
@item C-M-h |
1686 |
Put mark at the end of a function definition, and put point at the |
Put mark at the end of a function definition, and put point at the |
1687 |
beginning (@code{c-mark-function}). |
beginning (@code{c-mark-function}). |
1742 |
@itemx M-x global-cwarn-mode |
@itemx M-x global-cwarn-mode |
1743 |
@findex cwarn-mode |
@findex cwarn-mode |
1744 |
@findex global-cwarn-mode |
@findex global-cwarn-mode |
1745 |
|
@vindex global-cwarn-mode |
1746 |
@cindex CWarn mode |
@cindex CWarn mode |
1747 |
@cindex suspicious constructions in C, C++ |
@cindex suspicious constructions in C, C++ |
1748 |
CWarn minor mode highlights certain suspicious C and C++ constructions: |
CWarn minor mode highlights certain suspicious C and C++ constructions: |
1782 |
names. |
names. |
1783 |
@end table |
@end table |
1784 |
|
|
|
@node Comments in C |
|
|
@subsection Comments in C Modes |
|
|
|
|
|
C mode and related modes use a number of variables for controlling |
|
|
comment format. |
|
|
|
|
|
@table @code |
|
|
@item c-comment-only-line-offset |
|
|
@vindex c-comment-only-line-offset |
|
|
Extra offset for line which contains only the start of a comment. It |
|
|
can be either an integer or a cons cell of the form |
|
|
@code{(@var{non-anchored-offset} . @var{anchored-offset})}, where |
|
|
@var{non-anchored-offset} is the amount of offset given to |
|
|
non-column-zero anchored comment-only lines, and @var{anchored-offset} |
|
|
is the amount of offset to give column-zero anchored comment-only lines. |
|
|
Just an integer as value is equivalent to @code{(@var{val} . 0)}. |
|
|
|
|
|
@item c-comment-start-regexp |
|
|
@vindex c-comment-start-regexp |
|
|
This buffer-local variable specifies how to recognize the start of a comment. |
|
|
|
|
|
@item c-hanging-comment-ender-p |
|
|
@vindex c-hanging-comment-ender-p |
|
|
If this variable is @code{nil}, @code{c-fill-paragraph} leaves the |
|
|
comment terminator of a block comment on a line by itself. The default |
|
|
value is @code{t}, which puts the comment-end delimiter @samp{*/} at the |
|
|
end of the last line of the comment text. |
|
|
|
|
|
@item c-hanging-comment-starter-p |
|
|
@vindex c-hanging-comment-starter-p |
|
|
If this variable is @code{nil}, @code{c-fill-paragraph} leaves the |
|
|
starting delimiter of a block comment on a line by itself. The default |
|
|
value is @code{t}, which puts the comment-start delimiter @samp{/*} at |
|
|
the beginning of the first line of the comment text. |
|
|
@end table |
|
|
|
|
1785 |
@node Fortran |
@node Fortran |
1786 |
@section Fortran Mode |
@section Fortran Mode |
1787 |
@cindex Fortran mode |
@cindex Fortran mode |