11.5 Other Special Indentations

To configure macros which you invoke without a terminating ‘;’, see Macros with semicolons.

Here are the remaining odds and ends regarding indentation:

User Option: c-label-minimum-indentation

In ‘gnu’ style (see Built-in Styles), a minimum indentation is imposed on lines inside code blocks. This minimum indentation is controlled by this style variable. The default value is 1.

It’s the function c-gnu-impose-minimum that enforces this minimum indentation. It must be present on c-special-indent-hook to work.

User Option: c-special-indent-hook

This style variable is a standard hook variable that is called after every line is indented by CC Mode. It is called only if c-syntactic-indentation is non-nil (which it is by default (see Indentation Engine Basics)). You can put a function on this hook to do any special indentation or ad hoc line adjustments your style dictates, such as adding extra indentation to constructors or destructor declarations in a class definition, etc. Sometimes it is better to write a custom Line-up Function instead (see Custom Line-Up Functions).

When the indentation engine calls this hook, the variable c-syntactic-context is bound to the current syntactic context (i.e., what you would get by typing C-c C-s on the source line. See Custom Brace Hanging.). Note that you should not change point or mark inside a c-special-indent-hook function, i.e., you’ll probably want to wrap your function in a save-excursion50.

Setting c-special-indent-hook in style definitions is handled slightly differently from other variables—A style can only add functions to this hook, not remove them. See Style Variables.



The numerical value returned by point will change if you change the indentation of the line within a save-excursion form, but point itself will still be over the same piece of text.