如果宏未定义,我希望我的 emacs 将代码颜色更改为灰色,并且在 #ifdef #else 的情况下,也需要适当的缩进。
#define MY_MACRO
#ifdef MY_MACRO
int foo = 0;//proper indent, normal color
#else
int bar = 0;//proper indent, and gray color
如果宏未定义,我希望我的 emacs 将代码颜色更改为灰色,并且在 #ifdef #else 的情况下,也需要适当的缩进。
#define MY_MACRO
#ifdef MY_MACRO
int foo = 0;//proper indent, normal color
#else
int bar = 0;//proper indent, and gray color
Emacs 有一个hide-ifdef-mode
.
在 hide-ifdef-mode 中,C 预处理器将消除的#ifdef 结构中的代码可能会隐藏在视图之外。
它可以通过激活M-x hide-ifdef-mode
。对于基本用法,请使用该功能hide-ifdefs
(默认快捷方式C-c @ h
)。`
#define MY_MACRO
#ifdef MY_MACRO
int foo = 0;//proper indent, normal color
#else...
#endif
要恢复效果,请使用函数show-ifdefs
(默认快捷方式C-c @ s
):
#define MY_MACRO
#ifdef MY_MACRO
int foo = 0;//proper indent, normal color
#else
int bar = 0;//proper indent, and gray color
#endif