| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Often there are cases when a simple offset setting on a syntactic symbol isn't enough to get the desired indentation. Therefore, it's also possible to use a indentation function (a.k.a. line-up function) for a syntactic symbol.
CC Mode comes with many predefined indentation functions for common situations. If none of these does what you want, you can write your own, see 7.5.1 Custom Indentation Functions. If you do, it's probably a good idea to start working from one of these predefined functions, they can be found in the file `cc-align.el'.
For every function below there is a "works with" list that indicates which syntactic symbols the function is intended to be used with.
c-lineup-arglist
Works with: arglist-cont-nonempty.
c-lineup-arglist-intro-after-paren
Works with: defun-block-intro, brace-list-intro,
statement-block-intro, statement-case-intro,
arglist-intro.
c-lineup-arglist-close-under-paren
arglist-close syntactic symbol to this line-up
function so that parentheses that close argument lists will line up
under the parenthesis that opened the argument list.
Works with: defun-close, class-close, inline-close,
block-close, brace-list-close, arglist-close,
extern-lang-close, namespace-close (for most of these, a
zero offset will normally produce the same result, though).
c-lineup-close-paren
main (int,
char **
) // c-lineup-close-paren
|
main (
int, char **
) // c-lineup-close-paren
|
Works with: defun-close, class-close, inline-close,
block-close, brace-list-close, arglist-close,
extern-lang-close, namespace-close.
c-lineup-streamop
Works with: stream-op.
c-lineup-multi-inher
Foo::Foo (int a, int b):
Cyphr (a),
Bar (b) // c-lineup-multi-inher
|
class Foo
: public Cyphr,
public Bar // c-lineup-multi-inher
|
Foo::Foo (int a, int b)
: Cyphr (a)
, Bar (b) // c-lineup-multi-inher
|
Works with: inher-cont, member-init-cont.
c-lineup-java-inher
c-basic-offset to the column of the keyword.
E.g:
class Foo
extends
Bar // c-lineup-java-inher
<--> c-basic-offset
|
class Foo
extends Cyphr,
Bar // c-lineup-java-inher
|
Works with: inher-cont.
c-lineup-java-throws
c-basic-offset to the
column of the `throws' keyword. The `throws' keyword itself
is also indented by c-basic-offset from the function declaration
start if it doesn't hang. E.g:
int foo()
throws // c-lineup-java-throws
Bar // c-lineup-java-throws
<--><--> c-basic-offset
|
int foo() throws Cyphr,
Bar, // c-lineup-java-throws
Vlod // c-lineup-java-throws
|
Works with: func-decl-cont.
c-indent-one-line-block
c-basic-offset extra. E.g:
if (n > 0)
{m+=n; n=0;} // c-indent-one-line-block
<--> c-basic-offset
|
if (n > 0)
{ // c-indent-one-line-block
m+=n; n=0;
}
|
The block may be surrounded by any kind of parenthesis characters.
nil is returned if the line doesn't start with a one line block,
which makes the function usable in list expressions.
Works with: Almost all syntactic symbols, but most useful on the
-open symbols.
c-indent-multi-line-block
c-basic-offset extra. E.g:
int *foo[] = {
NULL,
{17}, // c-indent-multi-line-block
|
int *foo[] = {
NULL,
{ // c-indent-multi-line-block
17
},
<--> c-basic-offset
|
The block may be surrounded by any kind of parenthesis characters.
nil is returned if the line doesn't start with a multi line
block, which makes the function usable in list expressions.
Works with: Almost all syntactic symbols, but most useful on the
-open symbols.
c-lineup-C-comments
The style variable c-comment-prefix-regexp is used to recognize
the comment line prefix, e.g. the `*' that usually starts every
line inside a comment.
Works with: The c syntactic symbol.
c-lineup-comment
c-comment-only-line-offset. If the comment is lined up with a
comment starter on the previous line, that alignment is preserved.
c-comment-only-line-offset specifies the extra offset for the
line. It can contain an integer or a cons cell of the form
(<non-anchored-offset> . <anchored-offset>) |
where non-anchored-offset is the amount of offset given to
non-column-zero anchored lines, and anchored-offset is the amount
of offset to give column-zero anchored lines. Just an integer as value
is equivalent to (<value> . -1000).
Works with: comment-intro.
c-lineup-runin-statements
int main()
{ puts (\"Hello world!\");
return 0; // c-lineup-runin-statements
}
|
If there is no statement after the opening brace to align with,
nil is returned. This makes the function usable in list
expressions.
Works with: The statement syntactic symbol.
c-lineup-math
c-basic-offset. If
the current line contains an equal sign too, try to align it with the
first one.
Works with: statement-cont.
c-lineup-template-args
To allow this function to be used in a list expression, nil is
returned if there's no template argument on the first line.
Works with: template-args-cont.
c-lineup-ObjC-method-call
elisp-mode does
with function args: go to the position right after the message receiver,
and if you are at the end of the line, indent the current line
c-basic-offset columns from the opening bracket; otherwise you are
looking at the first character of the first method call argument, so
lineup the current line with it.
Works with: objc-method-call-cont.
c-lineup-ObjC-method-args
Works with: objc-method-args-cont.
c-lineup-ObjC-method-args-2
c-lineup-ObjC-method-args but lines up the colon on
the current line with the colon on the previous line.
Works with: objc-method-args-cont.
c-lineup-inexpr-block
nil if the block isn't part of such a
construct.
Works with: inlambda, inexpr-statement,
inexpr-class.
c-lineup-whitesmith-in-block
something
{
foo; // c-lineup-whitesmith-in-block
}
|
something {
foo; // c-lineup-whitesmith-in-block
}
<--> c-basic-offset
|
In the first case the indentation is kept unchanged, in the second
c-basic-offset is added.
Works with: defun-close, defun-block-intro,
block-close, brace-list-close, brace-list-intro,
statement-block-intro, inclass, inextern-lang,
innamespace.
c-lineup-dont-change
cpp-macro-cont lines.
Works with: Any syntactic symbol.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |