Next: , Previous: Interactive Customization, Up: Customizing Indentation

11.3 Line-Up Functions

Often there are cases when a simple offset setting on a syntactic symbol isn't enough to get the desired indentation—for example, you might want to line up a closing parenthesis with the matching opening one rather than indenting relative to its “anchor point”. CC Mode provides this flexibility with line-up functions.

The way you associate a line-up function with a syntactic symbol is described in c-offsets-alist. CC Mode comes with many predefined line-up functions for common situations. If none of these does what you want, you can write your own. See Custom Line-Up. Sometimes, it is easier to tweak the standard indentation by adding a function to c-special-indent-hook (see Other Indentation).

The line-up functions haven't been adapted for AWK buffers or tested with them. Some of them might work serendipitously. There shouldn't be any problems writing custom line-up functions for AWK mode.

The calling convention for line-up functions is described fully in Custom Line-Up. Roughly speaking, the return value is either an offset itself (such as + or [0]) or it's nil, meaning “this function is inappropriate in this case; try a different one”. See c-offsets-alist.

The subsections below describe all the standard line-up functions, categorized by the sort of token the lining-up centers around. For each of these functions there is a “works with” list that indicates which syntactic symbols the function is intended to be used with.