2011-05-17 36 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

相關問題