AFoglia
AFoglia

Reputation: 8128

Indenting template arguments in Emacs

I'm having no luck getting Emacs (cc-mode) to indent multiline template arguments. Here's an example line:

typedef ::boost::zip_iterator< ::boost::tuple<
vector<int>::const_iterator, vector<float>::const_iterator > >;

I'd like the second line to be indented, as like in a function. It is indented, until I enter the second-to-last >, at which point the second line up moves to the left to align with the typedef.

When I start typing the second line, the syntactic analysis is ((statement-cont 52)), until the second-to-last >, at which point it becomes ((defun-block-intro 46)). Deleting the character doesn't return to the old syntactic analysis.

I expected to have template-args-cont as the syntactic analysis.

I'm using the emacs 22.2 (ubuntu intrepid) and cc-mode version 5.31.5 that came with it.

Upvotes: 4

Views: 934

Answers (1)

Charlie Martin
Charlie Martin

Reputation: 112346

You should just need to set template-args-cont to some useful value. To experiment with it, put your cursor on the second line and enter C-cC-o for c-set-offset. Insert a convenient value. With 4, I get:

typedef ::boost::zip_iterator< ::boost::tuple<
    vector<int>::const_iterator, vector<float>::const_iterator > >; 

If that doesn't work, check your version: I have cc-mode version 5.31.6. To check, do M-x c-version. I get

Using CC Mode version 5.31.6

Upvotes: 3

Related Questions