【问题标题】:emacs, #ifdef macro color change, and indentemacs、#ifdef 宏颜色更改和缩进
【发布时间】:2016-11-28 03:52:40
【问题描述】:

如果宏未定义,我希望我的 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 syntax-highlighting font-lock


    【解决方案1】:

    Emacs 有一个hide-ifdef-mode

    在 hide-ifdef-mode 中,#ifdef 中的代码构造 C 预处理器将消除可能隐藏的视图。

    可以通过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
    

    【讨论】:

    • thanks@Lud,这是判断 MACRO 是否已定义的解决方案,但不是我想要的。我认为颜色更改会是一个更好的选择,因为我可以在没有'show-ifdefs' cmd 的情况下方便地看到 UNDEFINED 下的内容(虽然它也很方便)。所以我会让线程打开,并等待我的颜色更改解决方案.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 2011-08-07
    • 2017-10-13
    • 2010-11-07
    • 2013-07-16
    • 1970-01-01
    相关资源
    最近更新 更多