2011-05-17 60 views
3

如何让emacs缩进当前的续行(例如点或间接运算符后)比前一级更深一级?关于哪一个更漂亮的争论在这里是无关紧要的,因为这是我们在工作中使用的风格,所以我没有真正的选择。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; 
} 

回答

2

这是不可能的内置缩进选项。

您可以通过使用验证这个C-C C-S要在其中的/* extra indent */和他们上面的线,你会看到,这些线路的句法信息总是相同的线(又名c-show-syntactic-information)。换句话说,就缩进引擎所知,这些行在语法上是相同的。

查看interactive customization的文档。

可以通过自定义c-special-indent-hook来做你想做的事。

+1

嘿,特雷,我只是想说说阅读你的答案总是很高兴! – Thomas 2011-05-18 19:23:40

相关问题