1

With my actual configuration, an enum definition looks like this:

enum    Toto
    {
        foo,
        bar
    }

Spaces are by packs of 4 instead of 2 because I set 4 as default indentation space for C/C++.

I would like to align brackets with enum keyword WITHOUT reducing space between them and enum list, like this:

enum    Toto
{
    foo,
    bar
}

I already done a similar thing by totally canceling namespace indentation, with the following Elisp line:

(c-set-offset 'innamespace 0)

But I don't know if something similar is possible for enum.

1 Answer 1

3

You can adopt the same kind of solution as for your namespace definition, except you should use the brace-list-open identifier.

(c-set-offset 'brace-list-open 0)

After this setup, your code indents like this (with 2-space indentation):

enum Toto
{
  foo,
  bar
}


NB: You can find the correct indentation identifier using C-cC-s (c-show-syntactic-information) on any line of a C++ buffer. It will perform the syntactic analysis of the line and display the results. For example, when used in the { line above, it will highlight the first character of enum, and indicate in the minibuffer:

Syntactic analysis: ((brace-list-open 1))


Warning: Judging by the identifier name (brace-list-open), it might well be used for syntactic constructs other than enum. So you should expect side-effects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.