在emacs中缩进openmp指令作为C / C ++代码 [英] Indent openmp directives as C/C++ code in emacs

查看:124
本文介绍了在emacs中缩进openmp指令作为C / C ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以前的问题中,我学会了如何缩进宏作为emacs上的常规C代码。因为OpenMP中的 #pragma omp 指令,我只需要这个,但我想保留所有其他类型的宏,如 #if #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描述-variable c-offsets-alist ,它定义了表示各种编程语言的句法结构的变量列表,您只能看到 cpp-macro cpp-macro-cont 分别代表宏和连续宏。该列表在 #pragma 之间没有说明,并且说 #if

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.

这篇关于在emacs中缩进openmp指令作为C / C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆