11.3.5 Miscellaneous Line-Up Functions

The line-up functions here are the odds and ends which didn’t fit into any earlier category.

Function: c-lineup-dont-change

This lineup function makes the line stay at whatever indentation it already has; think of it as an identity function for lineups.

Works with:  Any syntactic symbol.

Function: c-lineup-under-anchor

Line up a line directly underneath its anchor point. This is like ‘0’, except any previously calculated offset contributions are disregarded.

Works with:  Any syntactic symbol which has an anchor point.

Function: c-lineup-cpp-define

Line up macro continuation lines according to the indentation of the construct preceding the macro. E.g.:

const char msg[] =    <- The beginning of the preceding construct.
  \"Some text.\";

#define X(A, B)  \
do {             \    <- c-lineup-cpp-define
  printf (A, B); \
} while (0)

and:

int dribble() {
  if (!running)       <- The beginning of the preceding construct.
    error(\"Not running!\");

#define X(A, B)    \
  do {             \  <- c-lineup-cpp-define
    printf (A, B); \
  } while (0)

If c-syntactic-indentation-in-macros is non-nil, the function returns the relative indentation to the macro start line to allow accumulation with other offsets. E.g., in the following cases, cpp-define-intro is combined with the statement-block-intro that comes from the ‘do {’ that hangs on the ‘#define’ line:

const char msg[] =
  \"Some text.\";

#define X(A, B) do { \
  printf (A, B);     \  <- c-lineup-cpp-define
  this->refs++;      \
} while (0)             <- c-lineup-cpp-define

and:

int dribble() {
  if (!running)
    error(\"Not running!\");

#define X(A, B) do { \
    printf (A, B);   \  <- c-lineup-cpp-define
    this->refs++;    \
  } while (0)           <- c-lineup-cpp-define

The relative indentation returned by c-lineup-cpp-define is zero and two, respectively, on the two lines in each of these examples. They are then added to the two column indentation that statement-block-intro gives in both cases here.

If the relative indentation is zero, then nil is returned instead. That is useful in a list expression to specify the default indentation on the top level.

If c-syntactic-indentation-in-macros is nil then this function keeps the current indentation, except for empty lines (ignoring the ending backslash) where it takes the indentation from the closest preceding nonempty line in the macro. If there’s no such line in the macro then the indentation is taken from the construct preceding it, as described above.

Works with:  cpp-define-intro.

Function: c-lineup-gcc-asm-reg

Line up a gcc asm register under one on a previous line.

    asm ("foo %1, %0\n"
         "bar %0, %1"
         : "=r" (w),
           "=r" (x)
         :  "0" (y),
            "1" (z));

The ‘x’ line is aligned to the text after the ‘:’ on the ‘w’ line, and similarly ‘z’ under ‘y’.

This is done only in an ‘asm’ or ‘__asm__’ block, and only to those lines mentioned. Anywhere else nil is returned. The usual arrangement is to have this routine as an extra feature at the start of arglist lineups, e.g.:

(c-lineup-gcc-asm-reg c-lineup-arglist)

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

Function: c-lineup-topmost-intro-cont

Line up declaration continuation lines zero or one indentation step48. For lines preceding a definition, zero is used. For other lines, c-basic-offset is added to the indentation. E.g.:

int
neg (int i)           <- c-lineup-topmost-intro-cont
{
    return -i;
}

and

struct
larch                 <- c-lineup-topmost-intro-cont
{
    double height;
}
    the_larch,        <- c-lineup-topmost-intro-cont
    another_larch;    <- c-lineup-topmost-intro-cont
<--> c-basic-offset

and

struct larch
the_larch,            <- c-lineup-topmost-intro-cont
    another_larch;    <- c-lineup-topmost-intro-cont

Works with:  topmost-intro-cont.


Footnotes

(48)

This function is mainly provided to mimic the behavior of CC Mode 5.28 and earlier where this case wasn’t handled consistently so that those lines could be analyzed as either topmost-intro-cont or statement-cont. It’s used for topmost-intro-cont by default, but you might consider using + instead.