Emacs - an extra layer for every continuous line

How do you tell emacs to indent the current line (for example, after the point operator or the indirectness operator) one level deeper than the previous? The arguments about which one is prettier are irrelevant here, since this is the style that we use in my work, so I have no choice.

I assume this is an offset (maybe statement-cont?), But I'm not sure how to do it dynamically ...

Related view: How to control indentation after an open bracket in Emacs

Have

#include <stdio.h>

struct thing {
    int the_first_piece_of_data;
};

struct stuff {
    struct thing the_first_thing_in_this_stuff;
    struct thing *pointer_to_the_first_thing_in_this_stuff;
};

int main(int argc, char *argv[])
{
    struct stuff some_stuff_to_work_with;
    struct stuff *pointer_to_stuff = &some_stuff_to_work_with;
    some_stuff_to_work_with.
        pointer_to_the_first_thing_in_this_stuff =
        &(some_stuff_to_work_with.
          the_first_thing_in_this_stuff);

    some_stuff_to_work_with.
        the_first_thing_in_this_stuff.
        the_first_piece_of_data = 42;

    printf("The piece of data is => %d\n",
           some_stuff_to_work_with.
           the_first_thing_in_this_stuff.
           the_first_piece_of_data);

    pointer_to_stuff->
        pointer_to_the_first_thing_in_this_stuff->
        the_first_piece_of_data++;

    printf("The piece of data is => %d\n",
           pointer_to_stuff->
           pointer_to_the_first_thing_in_this_stuff->
           the_first_piece_of_data);

    return 0;
}

Want to

#include <stdio.h>

struct thing {
    int the_first_piece_of_data;
};

struct stuff {
    struct thing the_first_thing_in_this_stuff;
    struct thing *pointer_to_the_first_thing_in_this_stuff;
};

int main(int argc, char *argv[])
{
    struct stuff some_stuff_to_work_with;
    struct stuff *pointer_to_stuff = &some_stuff_to_work_with;
    some_stuff_to_work_with.
        pointer_to_the_first_thing_in_this_stuff =
            &(some_stuff_to_work_with. /*exra indent*/
              the_first_thing_in_this_stuff);

    some_stuff_to_work_with.
        the_first_thing_in_this_stuff.
            the_first_piece_of_data = 42; /*exra indent*/

    printf("The piece of data is => %d\n",
           some_stuff_to_work_with.
               the_first_thing_in_this_stuff. /*exra indent*/
                   the_first_piece_of_data); /*exra indent*/

    pointer_to_stuff->
        pointer_to_the_first_thing_in_this_stuff->
            the_first_piece_of_data++; /*exra indent*/

    printf("The piece of data is => %d\n",
           pointer_to_stuff->
               pointer_to_the_first_thing_in_this_stuff-> /*exra indent*/
                   the_first_piece_of_data); /*exra indent*/

    return 0;
}
+3
source share
1 answer

This is not possible when using the indent options.

, C-c C-s (aka c-show-syntactic-information) , /* extra indent */ , , , , , .

.

, , , c-special-indent-hook.

+2

All Articles