aboutsummaryrefslogtreecommitdiffstats
path: root/man/programs.texi
diff options
context:
space:
mode:
authorKaroly Lorentey2005-12-26 03:16:59 +0000
committerKaroly Lorentey2005-12-26 03:16:59 +0000
commitfeba0cd6405ebb80af743e2f978442d9c837bcd2 (patch)
tree1cb964aa641bee514d9cda2eafe27a0a97e65ad1 /man/programs.texi
parent30663b475e57197c9896a252e1d4ca31c579fa2b (diff)
parent7a32e81fb608282314e27db21a00138aaa91f29a (diff)
downloademacs-feba0cd6405ebb80af743e2f978442d9c837bcd2.tar.gz
emacs-feba0cd6405ebb80af743e2f978442d9c837bcd2.zip
Merged from miles@gnu.org--gnu-2005 (patch 677)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-677 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-463
Diffstat (limited to 'man/programs.texi')
-rw-r--r--man/programs.texi396
1 files changed, 187 insertions, 209 deletions
diff --git a/man/programs.texi b/man/programs.texi
index 6444a3a6a47..e1806488150 100644
--- a/man/programs.texi
+++ b/man/programs.texi
@@ -128,17 +128,19 @@ place to set up customizations for that major mode. @xref{Hooks}.
128@node Defuns 128@node Defuns
129@section Top-Level Definitions, or Defuns 129@section Top-Level Definitions, or Defuns
130 130
131 In Emacs, a major definition at the top level in the buffer is 131 In Emacs, a major definition at the top level in the buffer,
132called a @dfn{defun}. The name comes from Lisp, but in Emacs we use 132something like a function, is called a @dfn{defun}. The name comes
133it for all languages. 133from Lisp, but in Emacs we use it for all languages.
134 134
135 In most programming language modes, Emacs assumes that a defun is 135 In many programming language modes, Emacs assumes that a defun is
136any pair of parentheses (or braces, if the language uses braces this 136any pair of parentheses (or braces, if the language uses braces this
137way) that starts at the left margin. For example, in C, the body of a 137way) that starts at the left margin. For example, in C, the body of a
138function definition is normally a defun, because the open-brace that 138function definition is a defun, usually recognized as an open-brace
139begins it is normally at the left margin. A variable's initializer 139that begins at the left margin@footnote{Alternatively, you can set up
140can also count as a defun, if the open-brace that begins the 140C Mode to recognize a defun at an opening brace at the outermost
141initializer is at the left margin. 141level. @xref{Movement Commands,,, ccmode, the CC Mode Manual}.}. A
142variable's initializer can also count as a defun, if the open-brace
143that begins the initializer is at the left margin.
142 144
143 However, some language modes provide their own code for recognizing 145 However, some language modes provide their own code for recognizing
144defuns in a way that suits the language syntax and conventions better. 146defuns in a way that suits the language syntax and conventions better.
@@ -156,14 +158,24 @@ defuns in a way that suits the language syntax and conventions better.
156 158
157@cindex open-parenthesis in leftmost column 159@cindex open-parenthesis in leftmost column
158@cindex ( in leftmost column 160@cindex ( in leftmost column
159 In most major modes, Emacs assumes that any opening delimiter found 161 Emacs assumes by default that any opening delimiter found at the
160at the left margin is the start of a top-level definition, or defun. 162left margin is the start of a top-level definition, or defun. You can
161Therefore, @strong{never put an opening delimiter at the left margin 163override this default by setting this user option:
162unless it should have that significance.} For instance, never put an 164
165@defvar open-paren-in-column-0-is-defun-start
166If this user option is set to @code{t} (the default), opening
167parentheses or braces at column zero always start defuns. When it's
168@code{nil}, defuns are found by searching for parens or braces at the
169outermost level. Some major modes, including C and related modes, set
170@code{open-paren-in-column-0-is-defun-start} buffer-locally to
171@code{nil}
172@end defvar
173
174 In modes where @code{open-paren-in-column-0-is-defun-start} is
175@code{t}, @strong{don't put an opening delimiter at the left margin
176unless it is a defun start}. For instance, never put an
163open-parenthesis at the left margin in a Lisp file unless it is the 177open-parenthesis at the left margin in a Lisp file unless it is the
164start of a top-level list. Never put an open-brace or other opening 178start of a top-level list.
165delimiter at the beginning of a line of C code unless it is at top
166level.
167 179
168 If you don't follow this convention, not only will you have trouble 180 If you don't follow this convention, not only will you have trouble
169when you explicitly use the commands for motion by defuns; other 181when you explicitly use the commands for motion by defuns; other
@@ -173,10 +185,10 @@ mode (@pxref{Font Lock}).
173 185
174 The most likely problem case is when you want an opening delimiter 186 The most likely problem case is when you want an opening delimiter
175at the start of a line inside a string. To avoid trouble, put an 187at the start of a line inside a string. To avoid trouble, put an
176escape character (@samp{\}, in C and Emacs Lisp, @samp{/} in some 188escape character (@samp{\}, in Emacs Lisp, @samp{/} in some other Lisp
177other Lisp dialects) before the opening delimiter. This will not 189dialects) before the opening delimiter. This will not affect the
178affect the contents of the string, but will prevent that opening 190contents of the string, but will prevent that opening delimiter from
179delimiter from starting a defun. Here's an example: 191starting a defun. Here's an example:
180 192
181@example 193@example
182 (insert "Foo: 194 (insert "Foo:
@@ -195,8 +207,9 @@ the beginning of the buffer, even for a small function. To speed up
195the operation, we changed Emacs to assume that any opening delimiter 207the operation, we changed Emacs to assume that any opening delimiter
196at the left margin is the start of a defun. This heuristic is nearly 208at the left margin is the start of a defun. This heuristic is nearly
197always right, and avoids the need to scan back to the beginning of the 209always right, and avoids the need to scan back to the beginning of the
198buffer. However, it mandates following the convention described 210buffer. However, now that modern computers are so powerful, this
199above. 211scanning is rarely slow enough to annoy, so we've provided a way to
212disable the heuristic.
200 213
201@node Moving by Defuns 214@node Moving by Defuns
202@subsection Moving by Defuns 215@subsection Moving by Defuns
@@ -399,13 +412,14 @@ behavior is convenient in cases where you have overridden the standard
399result of @key{TAB} because you find it unaesthetic for a particular 412result of @key{TAB} because you find it unaesthetic for a particular
400line. 413line.
401 414
402 Remember that an open-parenthesis, open-brace or other opening delimiter 415 By default, an open-parenthesis, open-brace or other opening
403at the left margin is assumed by Emacs (including the indentation routines) 416delimiter at the left margin is assumed by Emacs (including the
404to be the start of a function. Therefore, you must never have an opening 417indentation routines) to be the start of a function. This speeds up
405delimiter in column zero that is not the beginning of a function, not even 418indentation commands. If you will be editing text which contains
406inside a string. This restriction is vital for making the indentation 419opening delimiters in column zero that aren't the beginning of a
407commands fast; you must simply accept it. @xref{Left Margin Paren}, 420functions, even inside strings or comments, you must set
408for more information on this. 421@code{open-paren-in-column-0-is-defun-start}. @xref{Left Margin
422Paren}, for more information on this.
409 423
410 Normally, lines are indented with tabs and spaces. If you want Emacs 424 Normally, lines are indented with tabs and spaces. If you want Emacs
411to use spaces only, see @ref{Just Spaces}. 425to use spaces only, see @ref{Just Spaces}.
@@ -560,16 +574,16 @@ onto the indentation of the @dfn{anchor statement}.
560Select a predefined style @var{style} (@code{c-set-style}). 574Select a predefined style @var{style} (@code{c-set-style}).
561@end table 575@end table
562 576
563 A @dfn{style} is a named collection of customizations that can 577 A @dfn{style} is a named collection of customizations that can be
564be used in C mode and the related modes. Emacs comes with several 578used in C mode and the related modes. @ref{Styles,,, ccmode, The CC
579Mode Manual}, for a complete description. Emacs comes with several
565predefined styles, including @code{gnu}, @code{k&r}, @code{bsd}, 580predefined styles, including @code{gnu}, @code{k&r}, @code{bsd},
566@code{stroustrup}, @code{linux}, @code{python}, @code{java}, 581@code{stroustrup}, @code{linux}, @code{python}, @code{java},
567@code{whitesmith}, @code{ellemtel}, @code{cc-mode}, and @code{user}. 582@code{whitesmith}, @code{ellemtel}, and @code{awk}. Some of these
568Some of these styles are primarily intended for one language, but any 583styles are primarily intended for one language, but any of them can be
569of them can be used with any of the languages supported by these 584used with any of the languages supported by these modes. To find out
570modes. To find out what a style looks like, select it and reindent 585what a style looks like, select it and reindent some code, e.g., by
571some code, e.g., by typing @key{C-M-q} at the start of a function 586typing @key{C-M-q} at the start of a function definition.
572definition.
573 587
574@kindex C-c . @r{(C mode)} 588@kindex C-c . @r{(C mode)}
575@findex c-set-style 589@findex c-set-style
@@ -577,8 +591,8 @@ definition.
577.}. Specify a style name as an argument (case is not significant). 591.}. Specify a style name as an argument (case is not significant).
578This command affects the current buffer only, and it affects only 592This command affects the current buffer only, and it affects only
579future invocations of the indentation commands; it does not reindent 593future invocations of the indentation commands; it does not reindent
580the code in the buffer. To reindent the whole buffer in the new 594the code already in the buffer. To reindent the whole buffer in the
581style, you can type @kbd{C-x h C-M-\}. 595new style, you can type @kbd{C-x h C-M-\}.
582 596
583@vindex c-default-style 597@vindex c-default-style
584 You can also set the variable @code{c-default-style} to specify the 598 You can also set the variable @code{c-default-style} to specify the
@@ -589,23 +603,24 @@ example,
589 603
590@example 604@example
591(setq c-default-style 605(setq c-default-style
592 '((java-mode . "java") (other . "gnu"))) 606 '((java-mode . "java") (awk-mode . "awk") (other . "gnu")))
593@end example 607@end example
594 608
595@noindent 609@noindent
596specifies an explicit choice for Java mode, and the default @samp{gnu} 610specifies explicit choices for Java and AWK modes, and the default
597style for the other C-like modes. (These settings are actually the 611@samp{gnu} style for the other C-like modes. (These settings are
598defaults.) This variable takes effect when you select one of the 612actually the defaults.) This variable takes effect when you select
599C-like major modes; thus, if you specify a new default style for Java 613one of the C-like major modes; thus, if you specify a new default
600mode, you can make it take effect in an existing Java mode buffer by 614style for Java mode, you can make it take effect in an existing Java
601typing @kbd{M-x java-mode} there. 615mode buffer by typing @kbd{M-x java-mode} there.
602 616
603 The @code{gnu} style specifies the formatting recommended by the GNU 617 The @code{gnu} style specifies the formatting recommended by the GNU
604Project for C; it is the default, so as to encourage use of our 618Project for C; it is the default, so as to encourage use of our
605recommended style. 619recommended style.
606 620
607 @xref{Customizing Indentation,,, ccmode, the CC Mode Manual}, for 621 @xref{Indentation Engine Basics,,, ccmode, the CC Mode Manual}, and
608more information on customizing indentation for C and related modes, 622@ref{Customizing Indentation,,, ccmode, the CC Mode Manual}, for more
623information on customizing indentation for C and related modes,
609including how to override parts of an existing style and how to define 624including how to override parts of an existing style and how to define
610your own styles. 625your own styles.
611 626
@@ -708,11 +723,12 @@ would move over.
708 A somewhat random-sounding command which is nevertheless handy is 723 A somewhat random-sounding command which is nevertheless handy is
709@kbd{C-M-t} (@code{transpose-sexps}), which drags the previous 724@kbd{C-M-t} (@code{transpose-sexps}), which drags the previous
710balanced expression across the next one. An argument serves as a 725balanced expression across the next one. An argument serves as a
711repeat count, and a negative argument drags the previous balanced 726repeat count, moving the previous expression over that many following
712expression backwards across those before it (thus canceling out the 727ones. A negative argument drags the previous balanced expression
713effect of @kbd{C-M-t} with a positive argument). An argument of zero, 728backwards across those before it (thus canceling out the effect of
714rather than doing nothing, transposes the balanced expressions ending 729@kbd{C-M-t} with a positive argument). An argument of zero, rather
715at or after point and the mark. 730than doing nothing, transposes the balanced expressions ending at or
731after point and the mark.
716 732
717@kindex C-M-@@ 733@kindex C-M-@@
718@kindex C-M-@key{SPC} 734@kindex C-M-@key{SPC}
@@ -722,9 +738,9 @@ use @kbd{C-M-@@} (@code{mark-sexp}), which sets mark at the same place
722that @kbd{C-M-f} would move to. @kbd{C-M-@@} takes arguments like 738that @kbd{C-M-f} would move to. @kbd{C-M-@@} takes arguments like
723@kbd{C-M-f}. In particular, a negative argument is useful for putting 739@kbd{C-M-f}. In particular, a negative argument is useful for putting
724the mark at the beginning of the previous balanced expression. The 740the mark at the beginning of the previous balanced expression. The
725alias @kbd{C-M-@key{SPC}} is equivalent to @kbd{C-M-@@}. If you use 741alias @kbd{C-M-@key{SPC}} is equivalent to @kbd{C-M-@@}. When you
726this command repeatedly, or in Transient Mark mode whenever the mark 742repeat this command, or use it in Transient Mark mode when the mark is
727is active, it extends the region by one sexp each time. 743active, it extends the region by one sexp each time.
728 744
729 In languages that use infix operators, such as C, it is not possible 745 In languages that use infix operators, such as C, it is not possible
730to recognize all balanced expressions as such because there can be 746to recognize all balanced expressions as such because there can be
@@ -875,7 +891,7 @@ Set comment column (@code{comment-set-column}).
875@item @kbd{C-M-j} 891@item @kbd{C-M-j}
876@itemx @kbd{M-j} 892@itemx @kbd{M-j}
877Like @key{RET} followed by inserting and aligning a comment 893Like @key{RET} followed by inserting and aligning a comment
878(@code{comment-indent-new-line}). 894(@code{comment-indent-new-line}). @xref{Multi-Line Comments}.
879@item @kbd{M-x comment-region} 895@item @kbd{M-x comment-region}
880@itemx @kbd{C-c C-c} (in C-like modes) 896@itemx @kbd{C-c C-c} (in C-like modes)
881Add or remove comment delimiters on all the lines in the region. 897Add or remove comment delimiters on all the lines in the region.
@@ -948,8 +964,13 @@ and by not changing the indentation of a triple-semicolon comment at all.
948 (1+ x)) ; This line adds one. 964 (1+ x)) ; This line adds one.
949@end example 965@end example
950 966
951 In C code, a comment preceded on its line by nothing but whitespace 967 For C-like buffers, you can configure the exact effect of @kbd{M-;}
952is indented like a line of code. 968more flexibly than for most buffers by setting the user options
969@code{c-indent-comment-alist} and
970@code{c-indent-comments-syntactically-p}. For example, on a line
971ending in a closing brace, @kbd{M-;} puts the comment one space after
972the brace rather than at @code{comment-column}. For full details see
973@ref{Comment Commands,,, ccmode, The CC Mode Manual}.
953 974
954@node Multi-Line Comments 975@node Multi-Line Comments
955@subsection Multiple Lines of Comments 976@subsection Multiple Lines of Comments
@@ -958,23 +979,23 @@ is indented like a line of code.
958@kindex M-j 979@kindex M-j
959@cindex blank lines in programs 980@cindex blank lines in programs
960@findex comment-indent-new-line 981@findex comment-indent-new-line
982
961 If you are typing a comment and wish to continue it on another line, 983 If you are typing a comment and wish to continue it on another line,
962you can use the command @kbd{C-M-j} or @kbd{M-j} 984you can use the command @kbd{C-M-j} or @kbd{M-j}
963(@code{comment-indent-new-line}). This terminates the comment you are 985(@code{comment-indent-new-line}). If @code{comment-multi-line}
964typing, creates a new blank line afterward, and begins a new comment 986(@pxref{Options for Comments}) is non-@code{nil}, it moves to a new
965indented under the old one. When Auto Fill mode is on, going past the 987line within the comment. Otherwise it closes the comment and starts a
988new comment on a new line. When Auto Fill mode is on, going past the
966fill column while typing a comment causes the comment to be continued 989fill column while typing a comment causes the comment to be continued
967in just this fashion. If point is not at the end of the line when you 990in just this fashion.
968type the command, the text on the rest of the line becomes part of the
969new comment line.
970 991
971@kindex C-c C-c (C mode) 992@kindex C-c C-c (C mode)
972@findex comment-region 993@findex comment-region
973 To turn existing lines into comment lines, use the @kbd{M-x 994 To turn existing lines into comment lines, use the @kbd{M-x
974comment-region} command. It adds comment delimiters to the lines that start 995comment-region} command (or type @kbd{C-c C-c} in C-like buffers). It
975in the region, thus commenting them out. With a negative argument, it 996adds comment delimiters to the lines that start in the region, thus
976does the opposite---it deletes comment delimiters from the lines in the 997commenting them out. With a negative argument, it does the
977region. 998opposite---it deletes comment delimiters from the lines in the region.
978 999
979 With a positive argument, @code{comment-region} duplicates the last 1000 With a positive argument, @code{comment-region} duplicates the last
980character of the comment start sequence it adds; the argument specifies 1001character of the comment start sequence it adds; the argument specifies
@@ -985,6 +1006,11 @@ can also affect how the comment is indented. In Lisp, for proper
985indentation, you should use an argument of two or three, if between defuns; 1006indentation, you should use an argument of two or three, if between defuns;
986if within a defun, it must be three. 1007if within a defun, it must be three.
987 1008
1009 You can configure C Mode such that when you type a @samp{/} at the
1010start of a line in a multi-line block comment, this closes the
1011comment. Enable the @code{comment-close-slash} clean-up for this.
1012@xref{Clean-ups,,, ccmode, The CC Mode Manual}.
1013
988@node Options for Comments 1014@node Options for Comments
989@subsection Options Controlling Comments 1015@subsection Options Controlling Comments
990 1016
@@ -1038,13 +1064,13 @@ can hold the actual string to insert.
1038@vindex comment-multi-line 1064@vindex comment-multi-line
1039 The variable @code{comment-multi-line} controls how @kbd{C-M-j} 1065 The variable @code{comment-multi-line} controls how @kbd{C-M-j}
1040(@code{indent-new-comment-line}) behaves when used inside a comment. 1066(@code{indent-new-comment-line}) behaves when used inside a comment.
1041Specifically, when @code{comment-multi-line} is @code{nil} (the 1067Specifically, when @code{comment-multi-line} is @code{nil}, the
1042default value), the command inserts a comment terminator, begins a new 1068command inserts a comment terminator, begins a new line, and finally
1043line, and finally inserts a comment starter. Otherwise it does not 1069inserts a comment starter. Otherwise it does not insert the
1044insert the terminator and starter, so it effectively continues the 1070terminator and starter, so it effectively continues the current
1045current comment across multiple lines. In languages that allow 1071comment across multiple lines. In languages that allow multi-line
1046multi-line comments, the choice of value for this variable is a matter 1072comments, the choice of value for this variable is a matter of taste.
1047of taste. 1073The default for this variable depends on the major mode.
1048 1074
1049@vindex comment-indent-function 1075@vindex comment-indent-function
1050 The variable @code{comment-indent-function} should contain a function 1076 The variable @code{comment-indent-function} should contain a function
@@ -1510,11 +1536,13 @@ Move point to the end of the innermost C statement or sentence; like
1510 1536
1511@item M-x c-backward-into-nomenclature 1537@item M-x c-backward-into-nomenclature
1512@findex c-backward-into-nomenclature 1538@findex c-backward-into-nomenclature
1513Move point backward to beginning of a C++ nomenclature section or word. 1539Move point backward to beginning of a C++ nomenclature section or
1514With prefix argument @var{n}, move @var{n} times. If @var{n} is 1540word. With prefix argument @var{n}, move @var{n} times. If @var{n}
1515negative, move forward. C++ nomenclature means a symbol name in the 1541is negative, move forward. C++ nomenclature means a symbol name in
1516style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital letter 1542the style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital
1517begins a section or word. 1543letter begins a section or word. Rather than this command, you might
1544well prefer the newer ``Subword Mode'', which does the same thing
1545better. @xref{Other C Commands}.
1518 1546
1519In the GNU project, we recommend using underscores to separate words 1547In the GNU project, we recommend using underscores to separate words
1520within an identifier in C or C++, rather than using case distinctions. 1548within an identifier in C or C++, rather than using case distinctions.
@@ -1529,154 +1557,90 @@ With prefix argument @var{n}, move @var{n} times.
1529@subsection Electric C Characters 1557@subsection Electric C Characters
1530 1558
1531 In C mode and related modes, certain printing characters are 1559 In C mode and related modes, certain printing characters are
1532``electric''---in addition to inserting themselves, they also reindent 1560@dfn{electric}---in addition to inserting themselves, they also
1533the current line, and optionally also insert newlines. The 1561reindent the current line, and optionally also insert newlines. The
1534``electric'' characters are @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#}, 1562``electric'' characters are @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#},
1535@kbd{;}, @kbd{,}, @kbd{<}, @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and 1563@kbd{;}, @kbd{,}, @kbd{<}, @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and
1536@kbd{)}. 1564@kbd{)}.
1537 1565
1538 Electric characters insert newlines only when the @dfn{auto-newline} 1566 You might find electric indentation inconvenient if you are editing
1539feature is enabled (indicated by @samp{/a} in the mode line after the 1567chaotically indented code. If you are new to CC Mode, you might find
1540mode name). This feature is controlled by the variable 1568it disconcerting. You can toggle electric action with the command
1541@code{c-auto-newline}. You can turn this feature on or off with the 1569@kbd{C-c C-l}; when it is enabled, @samp{/l} appears in the mode line
1542command @kbd{C-c C-a}: 1570after the mode name:
1543 1571
1544@table @kbd 1572@table @kbd
1545@item C-c C-a 1573@item C-c C-l
1546@kindex C-c C-a @r{(C mode)} 1574@kindex C-c C-l @r{(C mode)}
1547@findex c-toggle-auto-state 1575@findex c-toggle-electric-state
1548Toggle the auto-newline feature (@code{c-toggle-auto-state}). With a 1576Toggle electric action (@code{c-toggle-electric-state}). With a
1549prefix argument, this command turns the auto-newline feature on if the 1577prefix argument, this command enables electric action if the argument
1550argument is positive, and off if it is negative. 1578is positive, disables it if it is negative.
1551@end table 1579@end table
1552 1580
1553 The colon character is electric because that is appropriate for a 1581 Electric characters insert newlines only when, in addition to the
1554single colon. But when you want to insert a double colon in C++, the 1582electric state, the @dfn{auto-newline} feature is enabled (indicated
1555electric behavior of colon is inconvenient. You can insert a double 1583by @samp{/la} in the mode line after the mode name). You can turn
1556colon with no reindentation or newlines by typing @kbd{C-c :}: 1584this feature on or off with the command @kbd{C-c C-a}:
1557 1585
1558@table @kbd 1586@table @kbd
1559@item C-c : 1587@item C-c C-a
1560@ifinfo 1588@kindex C-c C-a @r{(C mode)}
1561@c This uses ``colon'' instead of a literal `:' because Info cannot 1589@findex c-toggle-auto-newline
1562@c cope with a `:' in a menu 1590Toggle the auto-newline feature (@code{c-toggle-auto-newline}). With a
1563@kindex C-c @key{colon} @r{(C mode)} 1591prefix argument, this command turns the auto-newline feature on if the
1564@end ifinfo 1592argument is positive, and off if it is negative.
1565@ifnotinfo
1566@kindex C-c : @r{(C mode)}
1567@end ifnotinfo
1568@findex c-scope-operator
1569Insert a double colon scope operator at point, without reindenting the
1570line or adding any newlines (@code{c-scope-operator}).
1571@end table 1593@end table
1572 1594
1573@vindex c-electric-pound-behavior 1595 Usually the CC Mode style configures the exact circumstances in
1574 The electric @kbd{#} key reindents the line if it appears to be the 1596which Emacs inserts auto-newlines. You can also configure this
1575beginning of a preprocessor directive. This happens when the value of 1597directly. @xref{Custom Auto-newlines,,, ccmode, The CC Mode Manual}.
1576@code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn
1577this feature off by setting @code{c-electric-pound-behavior} to
1578@code{nil}.
1579
1580@vindex c-hanging-braces-alist
1581 The variable @code{c-hanging-braces-alist} controls the insertion of
1582newlines before and after inserted braces. It is an association list
1583with elements of the following form: @code{(@var{syntactic-symbol}
1584. @var{nl-list})}. Most of the syntactic symbols that appear in
1585@code{c-offsets-alist} are meaningful here as well.
1586
1587 The list @var{nl-list} may contain either of the symbols
1588@code{before} or @code{after}, or both; or it may be @code{nil}. When a
1589brace is inserted, the syntactic context it defines is looked up in
1590@code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used
1591to determine where newlines are inserted: either before the brace,
1592after, or both. If not found, the default is to insert a newline both
1593before and after braces.
1594
1595@vindex c-hanging-colons-alist
1596 The variable @code{c-hanging-colons-alist} controls the insertion of
1597newlines before and after inserted colons. It is an association list
1598with elements of the following form: @code{(@var{syntactic-symbol}
1599. @var{nl-list})}. The list @var{nl-list} may contain either of the
1600symbols @code{before} or @code{after}, or both; or it may be @code{nil}.
1601
1602 When a colon is inserted, the syntactic symbol it defines is looked
1603up in this list, and if found, the @var{nl-list} is used to determine
1604where newlines are inserted: either before the brace, after, or both.
1605If the syntactic symbol is not found in this list, no newlines are
1606inserted.
1607
1608@vindex c-cleanup-list
1609 Electric characters can also delete newlines automatically when the
1610auto-newline feature is enabled. This feature makes auto-newline more
1611acceptable, by deleting the newlines in the most common cases where you
1612do not want them. Emacs can recognize several cases in which deleting a
1613newline might be desirable; by setting the variable
1614@code{c-cleanup-list}, you can specify @emph{which} of these cases that
1615should happen. The variable's value is a list of symbols, each
1616describing one case for possible deletion of a newline. Here are the
1617meaningful symbols, and their meanings:
1618
1619@table @code
1620@item brace-catch-brace
1621Clean up @samp{@} catch (@var{condition}) @{} constructs by placing the
1622entire construct on a single line. The clean-up occurs when you type
1623the @samp{@{}, if there is nothing between the braces aside from
1624@code{catch} and @var{condition}.
1625
1626@item brace-else-brace
1627Clean up @samp{@} else @{} constructs by placing the entire construct on
1628a single line. The clean-up occurs when you type the @samp{@{} after
1629the @code{else}, but only if there is nothing but white space between
1630the braces and the @code{else}.
1631
1632@item brace-elseif-brace
1633Clean up @samp{@} else if (@dots{}) @{} constructs by placing the entire
1634construct on a single line. The clean-up occurs when you type the
1635@samp{@{}, if there is nothing but white space between the @samp{@}} and
1636@samp{@{} aside from the keywords and the @code{if}-condition.
1637
1638@item empty-defun-braces
1639Clean up empty defun braces by placing the braces on the same
1640line. Clean-up occurs when you type the closing brace.
1641
1642@item defun-close-semi
1643Clean up the semicolon after a @code{struct} or similar type
1644declaration, by placing the semicolon on the same line as the closing
1645brace. Clean-up occurs when you type the semicolon.
1646
1647@item list-close-comma
1648Clean up commas following braces in array and aggregate
1649initializers. Clean-up occurs when you type the comma.
1650
1651@item scope-operator
1652Clean up double colons which may designate a C++ scope operator, by
1653placing the colons together. Clean-up occurs when you type the second
1654colon, but only when the two colons are separated by nothing but
1655whitespace.
1656@end table
1657 1598
1658@node Hungry Delete 1599@node Hungry Delete
1659@subsection Hungry Delete Feature in C 1600@subsection Hungry Delete Feature in C
1660@cindex hungry deletion (C Mode) 1601@cindex hungry deletion (C Mode)
1661 1602
1662 When the @dfn{hungry-delete} feature is enabled (indicated by 1603 If you want to delete an entire block of whitespace at point, you
1663@samp{/h} or @samp{/ah} in the mode line after the mode name), a single 1604can use @dfn{hungry deletion}. This deletes all the contiguous
1664@key{DEL} command deletes all preceding whitespace, not just one space. 1605whitespace either before point or after point in a single operation.
1665To turn this feature on or off, use @kbd{C-c C-d}: 1606@dfn{Whitespace} here includes tabs and newlines, but not comments or
1607preprocessor commands.
1666 1608
1667@table @kbd 1609@table @kbd
1610@item C-c C-@key{BS}
1611@itemx C-c @key{BS}
1612@findex c-hungry-backspace
1613@kindex C-c C-@key{BS} (C Mode)
1614@kindex C-c @key{BS} (C Mode)
1615@code{c-hungry-backspace}---Delete the entire block of whitespace
1616preceding point.
1617
1668@item C-c C-d 1618@item C-c C-d
1669@kindex C-c C-d @r{(C mode)} 1619@itemx C-c C-@key{DEL}
1670@findex c-toggle-hungry-state 1620@itemx C-c @key{DEL}
1671Toggle the hungry-delete feature (@code{c-toggle-hungry-state}). With a 1621@findex c-hungry-delete-forward
1672prefix argument, this command turns the hungry-delete feature on if the 1622@kindex C-c C-d (C Mode)
1673argument is positive, and off if it is negative. 1623@kindex C-c C-@key{DEL} (C Mode)
1624@kindex C-c @key{DEL} (C Mode)
1625@code{c-hungry-delete-forward}---Delete the entire block of whitespace
1626following point.
1627@end table
1674 1628
1675@item C-c C-t 1629 As an alternative to the above commands, you can enable @dfn{hungry
1676@kindex C-c C-t @r{(C mode)} 1630delete mode}. When this feature is enabled (indicated by @samp{/h} in
1677@findex c-toggle-auto-hungry-state 1631the mode line after the mode name), a single @key{BS} command deletes
1678Toggle the auto-newline and hungry-delete features, both at once 1632all preceding whitespace, not just one space, and a single @kbd{C-c
1679(@code{c-toggle-auto-hungry-state}). 1633C-d} (but @emph{not} @key{delete}) deletes all following whitespace.
1634
1635@table @kbd
1636@item M-x c-toggle-hungry-state
1637@findex c-toggle-hungry-state
1638Toggle the hungry-delete feature
1639(@code{c-toggle-hungry-state})@footnote{This command had the binding
1640@kbd{C-c C-d} in earlier versions of Emacs. @kbd{C-c C-d} is now
1641bound to @code{c-hungry-delete-forward}.}. With a prefix argument,
1642this command turns the hungry-delete feature on if the argument is
1643positive, and off if it is negative.
1680@end table 1644@end table
1681 1645
1682@vindex c-hungry-delete-key 1646@vindex c-hungry-delete-key
@@ -1687,6 +1651,16 @@ hungry-delete feature is enabled.
1687@subsection Other Commands for C Mode 1651@subsection Other Commands for C Mode
1688 1652
1689@table @kbd 1653@table @kbd
1654@item C-c C-w
1655@itemx M-x c-subword-mode
1656@findex c-subword-mode
1657Enable (or disable) @dfn{subword mode}. In subword mode, Emacs's word
1658commands then recognize upper case letters in
1659@samp{StudlyCapsIdentifiers} as word boundaries. This is indicated by
1660the flag @samp{/w} on the mode line after the mode name
1661(e.g. @samp{C/law}). You can even use @kbd{M-x c-subword-mode} in
1662non-CC Mode buffers.
1663
1690@item M-x c-context-line-break 1664@item M-x c-context-line-break
1691@findex c-context-line-break 1665@findex c-context-line-break
1692This command inserts a line break and indents the new line in a manner 1666This command inserts a line break and indents the new line in a manner
@@ -1697,9 +1671,13 @@ it's like @kbd{M-j} (@code{c-indent-new-comment-line}).
1697 1671
1698@code{c-context-line-break} isn't bound to a key by default, but it 1672@code{c-context-line-break} isn't bound to a key by default, but it
1699needs a binding to be useful. The following code will bind it to 1673needs a binding to be useful. The following code will bind it to
1700@kbd{C-j}. 1674@kbd{C-j}. We use @code{c-initialization-hook} here to make sure
1675the keymap is loaded before we try to change it.
1676
1701@example 1677@example
1702(define-key c-mode-base-map "\C-j" 'c-context-line-break) 1678(defun my-bind-clb ()
1679 (define-key c-mode-base-map "\C-j" 'c-context-line-break))
1680(add-hook 'c-initialization-hook 'my-bind-clb)
1703@end example 1681@end example
1704 1682
1705@item C-M-h 1683@item C-M-h