【发布时间】:2011-05-17 18:41:09
【问题描述】:
你如何告诉 emacs 将当前续行缩进(例如,在点或间接运算符之后)比前一个更深一级?关于哪个更漂亮的争论在这里无关紧要,因为这是我们在工作中使用的风格,所以我真的别无选择。
我猜这是一个偏移量(可能是statement-cont?),但我不确定如何动态地做到这一点......
相关类型:How to control indentation after an open parenthesis in Emacs
有
#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;
}
想要
#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;
}
【问题讨论】:
标签: c++ c emacs indentation