缩进preprocessor指令在emacs的C $ C $Ç [英] Indent preprocessor directives as C code in emacs
问题描述
Emacs中,默认情况下,不缩进pre-处理器code。我知道它有历史根源,到现在已经过时了。
Emacs, by default, does not indent pre-processor code. I know it has historical roots that are obsolete by now.
然而,有一个code有很多的#ifdef的缩进是难以阅读。
However, having a code with a lot of #ifdef unindented is hard to read.
所以,我想提出emacs的自动缩进给我这样的事情:
So I would like to make emacs automatic indentation give me something like that:
void myfunc() {
int foo;
#ifdef BAR
printf(foo);
#endif
return foo;
}
而不是我现在得到:
Instead of what I get now :
void myfunc() {
int foo;
#ifdef BAR
printf(foo);
#endif
return foo;
}
在这个问题上的任何线索,你的Emacs的黑客:)?
Any leads on that issue you emacs hackers :) ?
推荐答案
您可以简单地告诉Emacs中添加一个偏移量pre-处理器产品线。
You can simply tell Emacs to add an offset to the pre-processor lines.
- 将光标(
点
)在pre-处理器产品线 - 然后preSS <大骨节病> C-C C-O 骨节病>(控制-C控制-O)
- 迷你缓冲区应该说
句法符号改变:
, - 键入
CPP宏
,preSS <大骨节病>输入骨节病> - 输入新的偏移量(数量 - 通常是
0
)
- Put the cursor (
point
) in a pre-processor line - then press C-c C-o (control-c control-o)
- the minibuffer should say
Syntactic symbol to change:
, - type
cpp-macro
, press Enter - Enter the new offset (number - usually
0
)
然后,<大骨节病>标签骨节病>每个pre-处理器产品线应该正确缩进它。 (或 M-X 骨节病> 缩进区域
...)。
Then a TAB on each pre-processor line should indent it correctly. (or M-xindent-region
...).
要发生改变永久设置,例如你可以添加所需的线在你的的.emacs
文件。
一个简单的方法,以复制previously输入的命令是<大骨节病> CX ESC ESC 骨节病>和使用箭头键来找到(C-设定偏移...)
elisp的命令。
To have the change set permanently, you can for instance add the required lines in your .emacs
file.
An easy way to copy a previously entered command is c-x ESC ESC and use the arrow keys to find the (c-set-offset ...)
Elisp command.
这应该是
(c-set-offset (quote cpp-macro) 0 nil)
这篇关于缩进preprocessor指令在emacs的C $ C $Ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!