Indent openmp directives as C/C++ code in emacs

房东的猫 提交于 2019-12-23 03:12:57

问题


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?


回答1:


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.

So, there is no direct way that Emacs provides to tell #pragma from other directives.



来源:https://stackoverflow.com/questions/5265205/indent-openmp-directives-as-c-c-code-in-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!