How do you tell emacs to indent the current continued line (e.g. after a dot or indirection operator) one level deeper than the previous one? Arguments about which one is prettier are irrelevant here since this is the style we use at my work, so I don't really have a choice.
I'm guessing it's an offset (maybe statement-cont
?), but I'm not sure how to do it dynamically like that...
Kind of related: How to control indentation after an open parenthesis 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
#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;
}