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.
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;
}
source
share