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

In a previous question, I found out how to backtrack macros as regular emacs C code. I just need this because of the #pragma omp from OpenMP, but I would like to keep all other macros like #if and #endif indented as by 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
source share
1 answer

If you look at Mx describe-variable c-offsets-alist , which defines a list of variables that represent the syntax constructs of various programming languages, you will only see cpp-macro and cpp-macro-cont , which represent macros and ongoing macros, respectively. The list does not indicate between #pragma and say #if .

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

+1
source

Source: https://habr.com/ru/post/907529/


All Articles