Previous: Noise Macros, Up: Custom Macros [Index]
Sometimes you may want to indent particular preprocessor directives
(e.g. #pragma
) as though they were statements. To do this,
first set up c-cpp-indent-to-body-directives
to include the
directive name(s), then enable the “indent to body” feature with
c-toggle-cpp-indent-to-body
.
This variable is a list of names of CPP directives (not including the
introducing ‘#’) which will be indented as though statements.
Each element is a string, and must be a valid identifier. The default
value is ("pragma")
.
If you add more directives to this variable, or remove directives from
it, whilst “indent to body” is active, you need to re-enable the
feature by calling c-toggle-cpp-indent-to-body
for these
changes to take effect52.
With M-x c-toggle-cpp-indent-to-body, you enable or disable the “indent to body” feature. When called programmatically, it takes an optional numerical argument. A positive value will enable the feature, a zero or negative value will disable it.
You should set up c-cpp-indent-to-body-directives
before
calling this function, since the function sets internal state which
depends on that variable.
Note that the removal of directives doesn’t work satisfactorally on XEmacs or on very old versions of Emacs