aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2007-01-01 22:19:41 +0000
committerAlan Mackenzie2007-01-01 22:19:41 +0000
commitcdae7c3ac0b1e37649da437f13401cba702ea803 (patch)
treec3255d590b502a3fdb811cb8c0f6a690c63107ac
parent51c9af45fee2a756cacbbcdb0628db558ca342e5 (diff)
downloademacs-cdae7c3ac0b1e37649da437f13401cba702ea803.tar.gz
emacs-cdae7c3ac0b1e37649da437f13401cba702ea803.zip
Changes for CC Mode 5.31.4. They are detailed in the ChangeLog entries
for 2007-01-01.
-rw-r--r--man/cc-mode.texi167
1 files changed, 100 insertions, 67 deletions
diff --git a/man/cc-mode.texi b/man/cc-mode.texi
index 801f098b9ce..e9a7d46d7fe 100644
--- a/man/cc-mode.texi
+++ b/man/cc-mode.texi
@@ -486,7 +486,7 @@ work just fine right out of the box. Note however that you might not
486have the latest @ccmode{} release and might want to upgrade your copy 486have the latest @ccmode{} release and might want to upgrade your copy
487(see below). 487(see below).
488 488
489You should probably start by reading the entire chapter 489You should probably start by skimming through the entire chapter
490@ref{Commands} to get an overview of @ccmode{}'s capabilities. 490@ref{Commands} to get an overview of @ccmode{}'s capabilities.
491 491
492After trying out some commands, you may dislike some aspects of 492After trying out some commands, you may dislike some aspects of
@@ -687,7 +687,7 @@ that begins at the line's left margin.
687@item 687@item
688When it's @code{nil}, the command indents the line by an extra 688When it's @code{nil}, the command indents the line by an extra
689@code{c-basic-offset} columns. A prefix argument acts as a 689@code{c-basic-offset} columns. A prefix argument acts as a
690multiplier. A bare prefix (@kbd{C-u @key{TAB}} is equivalent to -1, 690multiplier. A bare prefix (@kbd{C-u @key{TAB}}) is equivalent to -1,
691removing @code{c-basic-offset} columns from the indentation. 691removing @code{c-basic-offset} columns from the indentation.
692@end itemize 692@end itemize
693 693
@@ -880,30 +880,29 @@ lines.
880@ccmode{} contains some useful commands for moving around in C code. 880@ccmode{} contains some useful commands for moving around in C code.
881 881
882@table @asis 882@table @asis
883@item @kbd{M-x c-beginning-of-defun} 883@item @kbd{C-M-a}
884@itemx @kbd{M-x c-end-of-defun} 884@itemx @kbd{C-M-e}
885@findex c-beginning-of-defun 885@findex c-beginning-of-defun
886@findex c-end-of-defun 886@findex c-end-of-defun
887@findex beginning-of-defun (c-) 887
888@findex end-of-defun (c-) 888Move to the beginning or end of the current or next function. Other
889@findex beginning-of-defun 889constructs (such as a structs or classes) which have a brace block
890@findex end-of-defun 890also count as ``functions'' here. To move over several functions, you
891Move to the start or end of the current top-level definition. This is 891can give these commands a repeat count.
892the outermost brace pair which encloses point, together with the 892
893function header or similar preamble which precedes the opening brace. 893The start of a function is at its header. The end of the function is
894after its closing brace, or after the semicolon of a construct (such
895as a @code{struct}) which doesn't end at the brace. These two
896commands try to leave point at the beginning of a line near the actual
897start or end of the function. This occasionally causes point not to
898move at all.
899
894These functions are analogous to the Emacs built-in commands 900These functions are analogous to the Emacs built-in commands
895@code{beginning-of-defun} and @code{end-of-defun}, except they 901@code{beginning-of-defun} and @code{end-of-defun}, except they
896eliminate the constraint that the top-level opening brace of the defun 902eliminate the constraint that the top-level opening brace of the defun
897must be in column zero. See @ref{Defuns,,,@emacsman{}, 903must be in column zero. See @ref{Defuns,,,@emacsman{},
898@emacsmantitle{}}, for more information. 904@emacsmantitle{}}, for more information.
899 905
900Depending on the coding style you're using, you might prefer these two
901commands to the standard Emacs ones. If so, consider binding them to
902@kbd{C-M-a} and @kbd{C-M-e}. @xref{Sample .emacs File}. This
903customization won't affect the special bindings for these key
904sequences in force in AWK Mode. For backwards compatibility reasons,
905the default bindings for @kbd{C-M-a} and @kbd{C-M-e} remain in effect.
906
907@item @kbd{C-M-a} (AWK Mode) (@code{c-awk-beginning-of-defun}) 906@item @kbd{C-M-a} (AWK Mode) (@code{c-awk-beginning-of-defun})
908@itemx @kbd{C-M-e} (AWK Mode) (@code{c-awk-end-of-defun}) 907@itemx @kbd{C-M-e} (AWK Mode) (@code{c-awk-end-of-defun})
909@kindex C-M-a (AWK Mode) 908@kindex C-M-a (AWK Mode)
@@ -912,11 +911,9 @@ the default bindings for @kbd{C-M-a} and @kbd{C-M-e} remain in effect.
912@findex awk-beginning-of-defun (c-) 911@findex awk-beginning-of-defun (c-)
913@findex c-awk-end-of-defun 912@findex c-awk-end-of-defun
914@findex awk-end-of-defun (c-) 913@findex awk-end-of-defun (c-)
915Move back to the beginning or forward to the end of the current AWK 914Move to the beginning or end of the current or next AWK defun. These
916defun. These functions are bound to @kbd{C-M-a} and @kbd{C-M-e} by 915commands can take prefix-arguments, their functionality being entirely
917default in AWK Mode. They can take prefix-arguments, their 916equivalent to @code{beginning-of-defun} and @code{end-of-defun}.
918functionality being entirely equivalent to @code{beginning-of-defun}
919and @code{end-of-defun}.
920 917
921AWK Mode @dfn{defuns} are either pattern/action pairs (either of which 918AWK Mode @dfn{defuns} are either pattern/action pairs (either of which
922might be implicit) or user defined functions. Having the @samp{@{} and 919might be implicit) or user defined functions. Having the @samp{@{} and
@@ -1094,7 +1091,10 @@ prefix like @code{c-indent-new-comment-line}. In normal code it's
1094indented like @code{newline-and-indent} would do. In macros it acts 1091indented like @code{newline-and-indent} would do. In macros it acts
1095like @code{newline-and-indent} but additionally inserts and optionally 1092like @code{newline-and-indent} but additionally inserts and optionally
1096aligns the line ending backslash so that the macro remains unbroken. 1093aligns the line ending backslash so that the macro remains unbroken.
1097@xref{Custom Macros}, for details about the backslash alignment. 1094@xref{Custom Macros}, for details about the backslash alignment. In a
1095string, a backslash is inserted only if the string is within a
1096macro@footnote{In GCC, unescaped line breaks within strings are
1097valid.}.
1098 1098
1099This function is not bound to a key by default, but it's intended to be 1099This function is not bound to a key by default, but it's intended to be
1100used on the @kbd{RET} key. If you like the behavior of 1100used on the @kbd{RET} key. If you like the behavior of
@@ -1710,6 +1710,25 @@ buffers by typing @kbd{M-x c-subword-mode}.
1710Here are the various other commands that didn't fit anywhere else: 1710Here are the various other commands that didn't fit anywhere else:
1711 1711
1712@table @asis 1712@table @asis
1713@item @kbd{C-c .} (@code{c-set-style})
1714@kindex C-c .
1715@findex c-set-style
1716@findex set-style (c-)
1717Switch to the specified style in the current buffer. Use like this:
1718
1719@example
1720@kbd{C-c . @var{style-name} @key{RET}}
1721@end example
1722
1723You can use the @key{TAB} in the normal way to do completion on the
1724style name. Note that all style names are case insensitive, even the
1725ones you define yourself.
1726
1727Setting a style in this way does @emph{not} automatically reindent your
1728file. For commands that you can use to view the effect of your changes,
1729see @ref{Indentation Commands} and @ref{Filling and Breaking}.
1730
1731For details of the @ccmode{} style system, see @ref{Styles}.
1713@item @kbd{C-c :} (@code{c-scope-operator}) 1732@item @kbd{C-c :} (@code{c-scope-operator})
1714@kindex C-c : 1733@kindex C-c :
1715@findex c-scope-operator 1734@findex c-scope-operator
@@ -2363,7 +2382,7 @@ last thing when you enter that language mode.
2363@end defvar 2382@end defvar
2364 2383
2365Although these hooks are variables defined in @ccmode{}, you can give 2384Although these hooks are variables defined in @ccmode{}, you can give
2366them values before @ccmode{}'s code is loaded - indeed, this is the 2385them values before @ccmode{}'s code is loaded---indeed, this is the
2367only way to use @code{c-initialization-hook}. Their values aren't 2386only way to use @code{c-initialization-hook}. Their values aren't
2368overwritten when @ccmode{} gets loaded. 2387overwritten when @ccmode{} gets loaded.
2369 2388
@@ -2476,6 +2495,11 @@ Commas});@*
2476@cindex styles 2495@cindex styles
2477@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2496@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2478 2497
2498By @dfn{style} we mean the layout of the code---things like how many
2499columns to indent a block of code, whether an opening brace gets
2500indented to the level of the code it encloses, or of the construct
2501that introduces it, or ``hangs'' at the end of a line.
2502
2479Most people only need to edit code formatted in just a few well-defined 2503Most people only need to edit code formatted in just a few well-defined
2480and consistent styles. For example, their organization might impose a 2504and consistent styles. For example, their organization might impose a
2481``blessed'' style that all its programmers must conform to. Similarly, 2505``blessed'' style that all its programmers must conform to. Similarly,
@@ -2577,35 +2601,19 @@ afterwards.
2577@subsection Choosing a Style 2601@subsection Choosing a Style
2578@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2602@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2579 2603
2580Use @kbd{C-c .} to choose a style interactively: 2604When you create a new buffer, its style will be set from
2581 2605@code{c-default-style}. The factory default is the style @code{gnu},
2582@deffn Command c-set-style style-name 2606except in Java and AWK modes where it's @code{java} and @code{awk}.
2583@findex set-style (c-)
2584@kindex C-c .
2585Switch to the specified style in the current buffer. Use
2586interactively like this:
2587
2588@example
2589@kbd{C-c . @var{style-name} @key{RET}}
2590@end example
2591
2592You can use the @key{TAB} in the normal way to do completion on the
2593style name. Note that all style names are case insensitive, even the
2594ones you define yourself.
2595
2596Setting a style in this way does @emph{not} automatically reindent your
2597file. For commands that you can use to view the effect of your changes,
2598see @ref{Indentation Commands} and @ref{Filling and Breaking}.
2599@end deffn
2600
2601The default style in all newly created buffers is @code{gnu}, except
2602in Java and AWK modes where it's @code{java} and @code{awk}.
2603 2607
2604Remember that if you set a style variable with the Customization 2608Remember that if you set a style variable with the Customization
2605interface or at the top level of your @file{.emacs} file before the 2609interface or at the top level of your @file{.emacs} file before the
2606style system is initialised (@pxref{Config Basics}), this setting will 2610style system is initialised (@pxref{Config Basics}), this setting will
2607override the one that the style system would have given the variable. 2611override the one that the style system would have given the variable.
2608 2612
2613To set a buffer's style interactively, use the command @kbd{C-c .}
2614(@pxref{Other Commands}). To set it from a file's local variable
2615list, @ref{File Styles}.
2616
2609@defopt c-default-style 2617@defopt c-default-style
2610@vindex default-style (c-) 2618@vindex default-style (c-)
2611This variable specifies which style to install by default in new 2619This variable specifies which style to install by default in new
@@ -3247,8 +3255,8 @@ the proper functioning of @ccmode{}.
3247 3255
3248This variable is also bound in three other circumstances: 3256This variable is also bound in three other circumstances:
3249(i)@w{ }when calling a c-hanging-semi&comma-criteria function 3257(i)@w{ }when calling a c-hanging-semi&comma-criteria function
3250(@pxref{Hanging Semicolons and Commas}; (ii)@w{ }when calling a 3258(@pxref{Hanging Semicolons and Commas}); (ii)@w{ }when calling a
3251line-up function (@pxref{Custom Line-Up}; (iii)@w{ }when calling a 3259line-up function (@pxref{Custom Line-Up}); (iii)@w{ }when calling a
3252c-special-indent-hook function (@pxref{Other Indentation}). 3260c-special-indent-hook function (@pxref{Other Indentation}).
3253@end defvar 3261@end defvar
3254 3262
@@ -3430,7 +3438,11 @@ newlines after semicolons inside one-line inline method definitions
3430@dfn{Clean-ups} are mechanisms which remove (or exceptionally, add) 3438@dfn{Clean-ups} are mechanisms which remove (or exceptionally, add)
3431whitespace in specific circumstances and are complementary to colon 3439whitespace in specific circumstances and are complementary to colon
3432and brace hanging. You enable a clean-up by adding its symbol into 3440and brace hanging. You enable a clean-up by adding its symbol into
3433@code{c-cleanup-list}. 3441@code{c-cleanup-list}, e.g. like this:
3442
3443@example
3444(add-to-list 'c-cleanup-list 'space-before-funcall)
3445@end example
3434 3446
3435On the surface, it would seem that clean-ups overlap the functionality 3447On the surface, it would seem that clean-ups overlap the functionality
3436provided by the @code{c-hanging-*-alist} variables. Clean-ups, 3448provided by the @code{c-hanging-*-alist} variables. Clean-ups,
@@ -3661,10 +3673,11 @@ it's only an empty parenthesis pair. I.e. you will get @samp{signal
3661closing parenthesis is typed. 3673closing parenthesis is typed.
3662 3674
3663@item comment-close-slash 3675@item comment-close-slash
3664When inside a block comment, terminate the comment when you type a 3676When inside a block comment, terminate the comment when you type a slash
3665slash at the beginning of a line (i.e. immediately after the comment 3677at the beginning of a line (i.e. immediately after the comment prefix).
3666prefix). This clean-up removes whitespace preceding the slash and if 3678This clean-up removes whitespace preceding the slash and if needed,
3667needed, inserts a star to complete the token @samp{*/}. 3679inserts a star to complete the token @samp{*/}. Type @kbd{C-q /} in this
3680situation if you just want a literal @samp{/} inserted.
3668@end table 3681@end table
3669 3682
3670 3683
@@ -5182,7 +5195,7 @@ If an offset specification evaluates to @code{nil}, then a relative
5182offset of 0 (zero) is used@footnote{There is however a variable 5195offset of 0 (zero) is used@footnote{There is however a variable
5183@code{c-strict-syntax-p} that when set to non-@code{nil} will cause an 5196@code{c-strict-syntax-p} that when set to non-@code{nil} will cause an
5184error to be signaled in that case. It's now considered obsolete since 5197error to be signaled in that case. It's now considered obsolete since
5185it doesn't work well with some of the alignment functions that returns 5198it doesn't work well with some of the alignment functions that return
5186@code{nil} instead of zero. You should therefore leave 5199@code{nil} instead of zero. You should therefore leave
5187@code{c-strict-syntax-p} set to @code{nil}.}. 5200@code{c-strict-syntax-p} set to @code{nil}.}.
5188 5201
@@ -6549,18 +6562,16 @@ anchoring position to indent the line in that case.
6549@appendix Sample .emacs File 6562@appendix Sample .emacs File
6550@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6563@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6551 6564
6552@verbatim 6565Here's a sample .emacs file fragment that might help you along the way.
6553;; Here's a sample .emacs file fragment that might help you along the 6566Just copy this region and paste it into your .emacs file. You might want
6554;; way. Just copy this region and paste it into your .emacs file. 6567to change some of the actual values.
6555;; You might want to change some of the actual values.
6556 6568
6557;; Make some non-standard key bindings. We can put these in 6569@verbatim
6570;; Make a non-standard key binding. We can put this in
6558;; c-mode-base-map because c-mode-map, c++-mode-map, and so on, 6571;; c-mode-base-map because c-mode-map, c++-mode-map, and so on,
6559;; inherit from it. 6572;; inherit from it.
6560(defun my-c-initialization-hook () 6573(defun my-c-initialization-hook ()
6561 (define-key c-mode-base-map "\C-m" 'c-context-line-break) 6574 (define-key c-mode-base-map "\C-m" 'c-context-line-break))
6562 (define-key c-mode-base-map [?\C-\M-a] 'c-beginning-of-defun)
6563 (define-key c-mode-base-map [?\C-\M-e] 'c-end-of-defun))
6564(add-hook 'c-initialization-hook 'my-c-initialization-hook) 6575(add-hook 'c-initialization-hook 'my-c-initialization-hook)
6565 6576
6566;; offset customizations not in my-c-style 6577;; offset customizations not in my-c-style
@@ -6647,9 +6658,6 @@ embodied in the @code{beginning-of-defun} function. @ccmode now
6647caches syntactic information much better, so that the delay caused by 6658caches syntactic information much better, so that the delay caused by
6648searching for such a brace when it's not in column 0 is minimal, 6659searching for such a brace when it's not in column 0 is minimal,
6649except perhaps when you've just moved a long way inside the file. 6660except perhaps when you've just moved a long way inside the file.
6650Don't forget to rebind @kbd{C-M-a} and @kbd{C-M-e} to the @ccmode{}
6651functions @code{beginning-of-defun} and @code{end-of-defun} if you're
6652going to be hanging your braces! @xref{Sample .emacs File}.
6653 6661
6654@findex defun-prompt-regexp 6662@findex defun-prompt-regexp
6655@vindex c-Java-defun-prompt-regexp 6663@vindex c-Java-defun-prompt-regexp
@@ -6726,6 +6734,12 @@ more info.
6726 6734
6727@itemize @bullet 6735@itemize @bullet
6728@item 6736@item
6737@ccmode{} doesn't support trigraphs. (These are character sequences
6738such as @samp{??(}, which represents @samp{[}. They date from a time
6739when some character sets didn't have all the characters that C needs,
6740and are now utterly obsolete.)
6741
6742@item
6729There is no way to apply auto newline settings (@pxref{Auto-newlines}) 6743There is no way to apply auto newline settings (@pxref{Auto-newlines})
6730on already typed lines. That's only a feature to ease interactive 6744on already typed lines. That's only a feature to ease interactive
6731editing. 6745editing.
@@ -6747,6 +6761,25 @@ When a non-nested template is used in a declaration, @ccmode{} indents
6747it and font-locks it OK. Templates used in expressions, and nested 6761it and font-locks it OK. Templates used in expressions, and nested
6748templates do not fare so well. Sometimes a workaround is to refontify 6762templates do not fare so well. Sometimes a workaround is to refontify
6749the expression after typing the closing @samp{>}. 6763the expression after typing the closing @samp{>}.
6764
6765@item
6766On loading @ccmode{}, sometimes this error message appears:
6767
6768@example
6769File mode specification error: (void-variable c-font-lock-keywords-3)
6770@end example
6771
6772This is due to a bug in the function @code{eval-after-load} in some
6773versions of (X)Emacs. It can manifest itself when there is a symbolic
6774link in the path of the directory which contains (X)Emacs. As a
6775workaround, put the following into your @file{.emacs} file, fairly
6776early on:
6777
6778@example
6779(defun my-load-cc-fonts ()
6780 (require "cc-fonts"))
6781(add-hook 'c-initialization-hook 'my-load-cc-fonts)
6782@end example
6750@end itemize 6783@end itemize
6751 6784
6752@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6785@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!