I’m trying to get emacs to correctly format the ‘for each’ construct in c++.
I want the braces to be lined up with the f in for in both of the following examples:
for each(Type a in b) { //^c^s shows substatement-open //... do stuff } for( ; ; ) { //^c^s shows substatement-open //... do stuff }
In both cases, using [Ctrl-c Ctrl-s] (or [Ctrl-c Ctrl-o]) shows that both opening { characters are of type substatement-open and when viewing the c-offsets-alist I see that substatement-open is equal to 0.
How can I make emacs indent the for each() command similar to how it indents the for(;;) command?
Presumably emacs is not recognising ‘
for each‘ as c++ syntax (I don’t either. Is this a microsoft extension? A preprocessor hack? New for the upcoming standard?). So there is no wonder that it is not formatting it ‘right’.You could hack the mode, or ask the maintainer of the same (I wouldn’t expect a possitive response, though, unless this is going to be proper c++ Very Soon Now).
From the comments The answers to my parenthetical questions are:
BOOST_FOREACHavailable nowfor( <type> <loopcounter> : <container> )and from slink’s answer it appears that the mode maintainer is supporting the Microsoft syntax in the latest versions…