ccmode: Hanging Colons
8.2 Hanging Colons
==================
Using a mechanism similar to brace hanging (Hanging Braces),
colons can also be made to hang using the style variable
‘c-hanging-colons-alist’: when a colon is typed, CC Mode determines its
syntactic context, looks this up in the alist ‘c-changing-colons-alist’
and inserts up to two newlines accordingly. Here, however, If CC Mode
fails to find an entry for a syntactic symbol in the alist, no newlines
are inserted around the newly typed colon.
-- User Option: c-hanging-colons-alist
The Key: the syntactic symbol
The syntactic symbols appropriate as keys in this association
list are: ‘case-label’, ‘label’, ‘access-label’,
‘member-init-intro’, and ‘inher-intro’. Syntactic
Symbols. Elements with any other value as a key get
ignored.
The associated value: the “ACTION” list
The ACTION here is simply a list containing a combination of
the symbols ‘before’ and ‘after’. Unlike in
‘c-hanging-braces-alist’, functions as ACTIONS are not
supported; there doesn’t seem to be any need for them.
In C++, double-colons are used as a scope operator but because these
colons always appear right next to each other, newlines before and after
them are controlled by a different mechanism, called “clean-ups” in CC
Mode. Clean-ups, for details.