Next: , Previous: , Up: Line-Up Functions   [Contents][Index]

11.3.2 List Line-Up Functions

The line-up functions here calculate the indentation for lines which form lists of items, usually separated by commas.

The function c-lineup-arglist-close-under-paren, which is mainly for indenting a close parenthesis, is also useful for the lines contained within parentheses.

Function: c-lineup-arglist

Line up the current argument line under the first argument.

As a special case, if an argument on the same line as the open parenthesis starts with a brace block opener, the indentation is c-basic-offset only. This is intended as a “DWIM” measure in cases like macros that contain statement blocks, e.g.:

A_VERY_LONG_MACRO_NAME ({
        some (code, with + long, lines * in[it]);
    });
<--> c-basic-offset

This is motivated partly because it’s more in line with how code blocks are handled, and partly since it approximates the behavior of earlier CC Mode versions, which due to inaccurate analysis tended to indent such cases this way.

Works with:  arglist-cont-nonempty, arglist-close.

Function: c-lineup-arglist-intro-after-paren

Line up a line to just after the open paren of the surrounding paren or brace block.

Works with:  defun-block-intro, brace-list-intro, statement-block-intro, statement-case-intro, arglist-intro.

Function: c-lineup-2nd-brace-entry-in-arglist

Line up the second entry of a brace block under the first, when the first line is also contained in an arglist or an enclosing brace on that line.

I.e. handle something like the following:

set_line (line_t {point_t{0.4, 0.2},
                  point_t{0.2, 0.5},       <- brace-list-intro
                  .....});
         ^ enclosing parenthesis.

The middle line of that example will have a syntactic context with three syntactic symbols, arglist-cont-nonempty, brace-list-intro, and brace-list-entry (see Brace List Symbols).

This function is intended for use in a list. If the construct being analyzed isn’t like the preceding, the function returns nil. Otherwise it returns the function c-lineup-arglist-intro-after-paren, which the caller then uses to perform indentation.

Works with:  brace-list-intro.

Function: c-lineup-class-decl-init-+

Line up the second entry of a class (etc.) initializer c-basic-offset characters in from the identifier when:

  1. The type is a class, struct, union, etc. (but not an enum);
  2. There is a brace block in the type declaration, specifying it; and
  3. The first element of the initializer is on the same line as its opening brace.

I.e. we have a construct like this:

struct STR {
    int i; float f;
} str_1 = {1, 1.7},
    str_2 = {2,
         3.1          <- brace-list-intro
    };
    <--> c-basic-offset

Note that the syntactic context of the brace-list-intro line also has a syntactic element with the symbol brace-list-entry (see Brace List Symbols).

This function is intended for use in a list. If the above structure isn’t present, the function returns nil, allowing a different offset specification to indent the line.

Works with:  brace-list-intro.

Function: c-lineup-class-decl-init-after-brace

Line up the second entry of a class (etc.) initializer after its opening brace when:

  1. The type is a class, struct, union, etc. (but not an enum);
  2. There is a brace block in the type declaration, specifying it; and
  3. The first element of the initializer is on the same line as its opening brace.

I.e. we have a construct like this:

struct STR {
    int i; float f;
} str_1 = {1, 1.7},
    str_2 = {2,
             3.1      <- brace-list-intro
    };

Note that the syntactic context of the brace-list-intro line also has a syntactic element with the symbol brace-list-entry (see Brace List Symbols). Also note that this function works by returning the symbol c-lineup-arglist-intro-after-paren, which the caller then uses to perform the indentation.

This function is intended for use in a list. If the above structure isn’t present, the function returns nil, allowing a different offset specification to indent the line.

Works with:  brace-list-intro.

Function: c-lineup-multi-inher

Line up the classes in C++ multiple inheritance clauses and member initializers under each other. E.g.:

Foo::Foo (int a, int b):
    Cyphr (a),
    Bar (b)           <- c-lineup-multi-inher

and

class Foo
    : public Cyphr,
      public Bar      <- c-lineup-multi-inher

and

Foo::Foo (int a, int b)
    : Cyphr (a)
    , Bar (b)         <- c-lineup-multi-inher

Works with:  inher-cont, member-init-cont.

Function: c-lineup-java-inher

Line up Java implements and extends declarations. If class names follow on the same line as the ‘implements’/‘extends’ keyword, they are lined up under each other. Otherwise, they are indented by adding c-basic-offset to the column of the keyword. E.g.:

class Foo
    extends
        Bar           <- c-lineup-java-inher
    <--> c-basic-offset

and

class Foo
    extends Cyphr,
            Bar       <- c-lineup-java-inher

Works with:  inher-cont.

Function: c-lineup-java-throws

Line up Java throws declarations. If exception names follow on the same line as the throws keyword, they are lined up under each other. Otherwise, they are indented by adding 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

and

int foo() throws Cyphr,
                 Bar,    <- c-lineup-java-throws
                 Vlod    <- c-lineup-java-throws

Works with:  func-decl-cont.

Function: c-lineup-template-args

Line up the arguments of a template argument list under each other, but only in the case where the first argument is on the same line as the opening ‘<’.

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.

Function: c-lineup-ObjC-method-call

For Objective-C code, line up selector args as Emacs Lisp 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.

Function: c-lineup-ObjC-method-args

For Objective-C code, line up the colons that separate args. The colon on the current line is aligned with the one on the first line.

Works with:  objc-method-args-cont.

Function: c-lineup-ObjC-method-args-2

Similar to 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.

Next: Operator Line-Up Functions, Previous: Brace and Parenthesis Line-Up Functions, Up: Line-Up Functions   [Contents][Index]