Emacs indentation difficulty

后端 未结 3 1432
小鲜肉
小鲜肉 2021-02-04 16:05

I\'m really trying to switch to emacs, but learning to setup the environment is a real pain. Everybody says it\'s worth it, so I just continue.

I want my c code to be im

3条回答
  •  星月不相逢
    2021-02-04 16:58

    Your defaults are possibly being overridden by cc-mode's style feature.

    Try initialising the default style like this:

    (setq c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "user")))

    You should be able to paste the preceding line into your .emacs file, or customize the c-default-style variable. The default has (other "gnu") as the last element of the list, which means that all non-Java and non-awk files get the gnu style instead of what you set with setq. The special user style gets initialised from your manually-set style variables.

    Another option is to pick one of the built-in styles instead of defining it yourself, or to create your own style using the c-add-style function. To do this, change "user" in the above command to the name of the style (as a string). Try the the stroustrup or python built-in styles to format if-statements how you want.

提交回复
热议问题