/[emacs]/emacs/man/cc-mode.texi
ViewVC logotype

Diff of /emacs/man/cc-mode.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18.4.4 by miles, Tue Jul 6 09:31:24 2004 UTC revision 1.18.4.5 by miles, Sat Sep 4 09:22:57 2004 UTC
# Line 1340  block comments. Line 1340  block comments.
1340  @findex setup-paragraph-variables (c-)  @findex setup-paragraph-variables (c-)
1341  Also note that since @ccmode{} uses the value of  Also note that since @ccmode{} uses the value of
1342  @code{c-comment-prefix-regexp} to set up several other variables at mode  @code{c-comment-prefix-regexp} to set up several other variables at mode
1343  initialization, there won't have any effect if you change it inside a  initialization, there won't be any effect if you just change it inside a
1344  @ccmode{} buffer.  You need to call the command  @ccmode{} buffer.  You need to call the command
1345  @code{c-setup-paragraph-variables} to update those other variables with  @code{c-setup-paragraph-variables} too, to update those other variables with
1346  the new value.  That's also the case if you modify this variable in a  the new value.  That's also the case if you modify this variable in a
1347  mode hook, since @ccmode{} sets up all variables before calling them.  mode hook, since @ccmode{} sets up all variables before calling them.
1348  @end defopt  @end defopt
# Line 1415  namely when a block comment is broken fo Line 1415  namely when a block comment is broken fo
1415  variable@footnote{In versions before 5.26, this variable was called  variable@footnote{In versions before 5.26, this variable was called
1416  @code{c-comment-continuation-stars}.  As a compatibility measure,  @code{c-comment-continuation-stars}.  As a compatibility measure,
1417  @ccmode{} still uses the value on that variable if it's set.} is used  @ccmode{} still uses the value on that variable if it's set.} is used
1418  then as the comment prefix.  It defaults to @samp{* }, which makes a  then as the comment prefix.  It defaults to @samp{*
1419  comment  }@footnote{Actually, this default setting of
1420    @code{c-block-comment-prefix} typically gets overriden by the default
1421    style @code{gnu}, which sets it to blank.  You can see the line
1422    splitting effect described here by setting a different style,
1423    e.g. @code{k&r} @xref{Choosing a Style}}, which makes a comment
1424    
1425  @example  @example
1426  /* Got O(n^2) here, which is a Bad Thing. */  /* Got O(n^2) here, which is a Bad Thing. */
# Line 2057  These variables are also useful when ind Line 2061  These variables are also useful when ind
2061  @vindex tab-always-indent (c-)  @vindex tab-always-indent (c-)
2062  @kindex TAB  @kindex TAB
2063  @cindex literal  @cindex literal
2064  This variable controls how @kbd{TAB} (@code{c-indent-command}) operates.  This variable controls how @kbd{TAB} (@code{c-indent-command})
2065  When it is @code{t}, @kbd{TAB} always indents the current line.  When it  operates.  When it is @code{t}, @kbd{TAB} always indents the current
2066  is @code{nil}, the line is indented only if point is at the left margin,  line.  When it is @code{nil}, the line is indented only if point is at
2067  or on or before the first non-whitespace character on the line,  the left margin, or on or before the first non-whitespace character on
2068  otherwise some whitespace is inserted.  If this variable is the symbol  the line, otherwise some whitespace is inserted.  If this variable is
2069  @code{other}, then some whitespace is inserted only within strings and  some other value (not @code{nil} or @code{t}), then some whitespace is
2070  comments (literals), and inside preprocessor directives, but the line is  inserted only within strings and comments (literals), but the line is
2071  always reindented.  always reindented.
2072  @end defopt  @end defopt
2073    
# Line 2878  string. Line 2882  string.
2882  @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2883  @node    Adding Styles, File Styles, Choosing a Style, Styles  @node    Adding Styles, File Styles, Choosing a Style, Styles
2884  @comment node-name, next, previous, up  @comment node-name, next, previous, up
2885  @subsection Adding Styles  @subsection Adding and Amending Styles
2886  @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2887    
2888  If none of the built-in styles is appropriate, you'll probably want to  If none of the built-in styles is appropriate, you'll probably want to
2889  add a new @dfn{style definition}.  Styles are kept in the  create a new @dfn{style definition}, possibly based on an existing
2890  @code{c-style-alist} variable, but you should never modify this  style.  To do this, put the new style's settings into a list with the
2891  variable directly.  Instead, @ccmode{} provides the function  following format - the list can then be passed as an argument to the
2892  @code{c-add-style} that you can use to easily add new styles or change  function @code{c-add-style}:
2893  existing styles:  
2894    @cindex style definition
2895    @defvr {List} style definition
2896    ([@var{base-style}] [(@var{variable} . @var{value}) @dots{}])
2897    
2898    Optional @var{base-style}, if present, must be a string which is the
2899    name of the @dfn{base style} from which this style inherits.  At most
2900    one @var{base-style} is allowed in a style definition.  If
2901    @var{base-style} is not specified, the style inherits from a table of
2902    default values@footnote{This table is stored internally in the
2903    variable c-fallback-style.  It is computed during the initialisation
2904    of @ccmode{} from the factory defaults of the style variables and any
2905    global values they may have been given since starting Emacs.} instead.
2906    All styles eventually inherit from this internal table.  Style loops
2907    generate errors.  The list of pre-existing styles can be seen in
2908    @ref{Built-in Styles}.
2909    
2910    The dotted pairs (@var{variable} . @var{value}) each consist of a
2911    variable and the value it is to be set to when the style is later
2912    activated.@footnote{In certain circumstances, this value can get
2913    overridden by another value.}  The variable can be either a @ccmode{}
2914    style variable or an arbitrary Emacs variable.  In the latter case, it
2915    is @emph{not} made buffer local by the @ccmode{} style system.
2916    @end defvr
2917    
2918    Two variables are treated specially in the dotted pair list:
2919    
2920    @table @code
2921    @item c-offsets-alist
2922    The value is in turn a dotted list on the form
2923    
2924    (@var{syntactic-symbol} . @var{offset})
2925    
2926    as described in @ref{Customizing Indentation}.  These are passed to
2927    @code{c-set-offset} so there is no need to set every syntactic symbol in
2928    your style, only those that are different from the inherited style.
2929    
2930    @item c-special-indent-hook
2931    The value is added to @code{c-special-indent-hook} using
2932    @code{add-hook}, so any functions already on it are kept.  If the value
2933    is a list, each element of the list is added with @code{add-hook}.
2934    @end table
2935    
2936    Styles are kept in the @code{c-style-alist} variable, but you
2937    should never modify this variable directly.  Instead, @ccmode{}
2938    provides the function @code{c-add-style} for this purpose.
2939    
2940  @defun c-add-style stylename description &optional set-p  @defun c-add-style stylename description &optional set-p
2941  @findex add-style (c-)  @findex add-style (c-)
2942  Add or update a style.  If @var{stylename} is not already in  Add or update a style called @var{stylename}, a string.
2943  @code{c-style-alist} then a new style according to @var{description}  @var{description} is the new style definition in the form described
2944  is added, otherwise the existing style is changed.  If the optional  above.  If @var{stylename} already exists in @code{c-style-alist} then
2945  @var{set-p} is non-@code{nil} then the new style is applied to the  it is replaced by @var{description}.  (Note, this replacement is
2946  current buffer as well.  total.  The old style is @emph{not} merged into the new one.)
2947    Otherwise, a new style is added.  If the optional @var{set-p} is
2948  @comment TBD: The next paragraph is bogus.  I really need to better  non-@code{nil} then the new style is applied to the current buffer as
2949  @comment document adding styles, including setting up inherited styles.  well.
2950    
2951  The sample @file{.emacs} file provides a concrete example of how a new  The sample @file{.emacs} file provides a concrete example of how a new
2952  style can be added and automatically set.  @xref{Sample .emacs File}.  style can be added and automatically set.  @xref{Sample .emacs File}.
# Line 3416  Analogous to @code{inclass} syntactic sy Line 3465  Analogous to @code{inclass} syntactic sy
3465  Lines continuing the header of a lambda function, i.e., between the  Lines continuing the header of a lambda function, i.e., between the
3466  @code{lambda} keyword and the function body.  Only used in Pike mode.  @code{lambda} keyword and the function body.  Only used in Pike mode.
3467  @item inexpr-statement  @item inexpr-statement
3468  A statement block inside an expression.  The gcc C extension of this is  A statement block inside an expression.  The gcc C and C++ extension for
3469  recognized.  It's also used for the special functions that takes a  this is recognized.  It's also used for the special functions that take
3470  statement block as an argument in Pike.  a statement block as an argument in Pike.
3471  @item inexpr-class  @item inexpr-class
3472  A class definition inside an expression.  This is used for anonymous  A class definition inside an expression.  This is used for anonymous
3473  classes in Java.  It's also used for anonymous array initializers in  classes in Java.  It's also used for anonymous array initializers in
# Line 4022  indented just like a normal class, with Line 4071  indented just like a normal class, with
4071  @code{inexpr-class}.  @code{inexpr-class}.
4072    
4073  There are a few occasions where a statement block may be used inside an  There are a few occasions where a statement block may be used inside an
4074  expression.  One is in C code using the gcc extension for this, e.g:  expression.  One is in C or C++ code using the gcc extension for this,
4075    e.g:
4076    
4077  @example  @example
4078   1: int res = (@{   1: int res = (@{
# Line 5225  Controls whether a final newline is ensu Line 5275  Controls whether a final newline is ensu
5275  value is an association list that for each language mode specifies the  value is an association list that for each language mode specifies the
5276  value to give to @code{require-final-newline} at mode initialization;  value to give to @code{require-final-newline} at mode initialization;
5277  see that variable for details about the value.  If a language isn't  see that variable for details about the value.  If a language isn't
5278  present on the association list, CC Mode won't set  present on the association list, CC Mode won't touch
5279  @code{require-final-newline} in buffers for that language.  @code{require-final-newline} in buffers for that language.
5280    
5281  The default is to set @code{require-final-newline} to @code{t} in the  The default is to set @code{require-final-newline} to @code{t} in the
# Line 5484  interpreter tries to call the macro as a Line 5534  interpreter tries to call the macro as a
5534  (somewhat cryptic) error message.}. If you are using the standalone  (somewhat cryptic) error message.}. If you are using the standalone
5535  @ccmode{} distribution, try recompiling it according to the instructions  @ccmode{} distribution, try recompiling it according to the instructions
5536  in the @file{README} file.  in the @file{README} file.
5537    
5538    @item
5539    @cindex open paren in column zero
5540    @emph{I have an open paren character at column zero inside a comment or
5541    multiline string literal, and it causes the fontification and/or
5542    indentation to go haywire.  What gives?}
5543    
5544    It's due to the ad-hoc rule in (X)Emacs that such open parens always
5545    start defuns (which translates to functions, classes, namespaces or any
5546    other top-level block constructs in the @ccmode{} languages).
5547    @xref{Left Margin Paren,,, emacs, The Emacs Editor}, for details
5548    (@xref{Defuns,,, emacs, The Emacs Editor}, in the Emacs 20 manual).
5549    
5550    This heuristic is built into the core syntax analysis routines in
5551    (X)Emacs, so it's not really a @ccmode{} issue.  However, in Emacs 21.4
5552    it has become possible to turn it off@footnote{Using the variable
5553    @code{open-paren-in-column-0-is-defun-start}.} and @ccmode{} does so
5554    there since it got its own system to keep track of blocks.
5555    
5556  @end itemize  @end itemize
5557    
5558    

Legend:
Removed from v.1.18.4.4  
changed lines
  Added in v.1.18.4.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26