缩进OpenMP指令在emacs的C / C ++ code [英] Indent openmp directives as C/C++ code in emacs
问题描述
在一个previous <一个href=\"http://stackoverflow.com/questions/4669219/indent-$p$pprocessor-directives-as-c-$c$c-in-emacs\">question,我学会了如何缩进宏作为emacs的常规C code。我只需要这个,因为的#pragma OMP
从OpenMP指令的,但我想保持所有其他类型的宏,如#如果
和 #ENDIF
,缩进为默认值。
In a previous question, I learned how to indent macros as regular C code on emacs. I just need this because of #pragma omp
directives from OpenMP, but I'd like to maintain all other kind of macros, like #if
and #endif
, indented as the default.
(c-set-offset (quote cpp-macro) 0 nil)
上面的规则对待所有的宏一样。我的问题是:有没有办法专注这个规则
The rule above treats all macros as the same. My question is: Is there a way to specialize this rule?
推荐答案
如果你看看的Mx描述变量C-偏移-ALIST
,它定义的变量列表那些重新present的各种编程语言的语法结构,你只看到 CPP宏
和 CPP-宏观续
从而重新present宏和持续宏分别。列表不的#pragma
之间的告诉说,#如果
。
If you look at M-x describe-variable c-offsets-alist
, which defines a list of variables that represent the syntactic constructs of the various programming languages, you'd only see cpp-macro
and cpp-macro-cont
which represent macros and continuing macros respectively. The list does not tell between #pragma
and say, #if
.
因此,有是的Emacs提供了从其他指令告诉的#pragma
没有直接的方法。
So, there is no direct way that Emacs provides to tell #pragma
from other directives.
这篇关于缩进OpenMP指令在emacs的C / C ++ code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!