Search code examples
emacselispindentationauto-indent

emacs cc-mode: indentation for multi-line lists in curly braces


I found a problem with the emacs cc-mode. Unfortunately, whenever I am trying to initialize an object with an initializer list that spans multiple lines, I receive the following indentation style:

S<int> s = {
    1,
        2,
        3
    }

I would prefer to have all elements to be indented with the equivalent spacing on every line. Does anyone know how this can be achieved?


Solution

  • The problem was that up until recently C++11 List initialisation hadn't been implemented, so CC Mode was struggling. It now has been implemented.

    There are three strategies for getting the new code, in order of increasing rapidity and increasing work: 1/- Wait for the code to be released in Emacs, probably in version 25.2. (several months', to over a year's wait). 2/- Wait for the code to be released in CC Mode in release 5.33.1. (Several week's wait). This will then be downloadable from http://cc-mode.sourceforge.net/release.php. 3/- Download the up to date source code repository version from CC Mode. (Instantaneous). Instructions can be found on http://cc-mode.sourceforge.net/hgaccess.php.