Using a mechanism similar to brace hanging (see 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.
- The Key - the syntactic symbol
- The syntactic symbols appropriate as keys in this association list are:
inher-intro. See Syntactic Symbols. Elements with any other value as a key get ignored.
- The associate value - the “ACTION” list
- The action here is simply a list containing a combination of the symbols
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. See Clean-ups, for details.