help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems formatting C++ with SWIG macros


From: dbmeyer030
Subject: Problems formatting C++ with SWIG macros
Date: Fri, 17 May 2013 10:05:51 -0700 (PDT)
User-agent: G2/1.0

Hi folks,

I've entered into an existing project that is written in C++. The team had 
previously agreed to abide by the Google coding standard for the C++ work, but 
with a few changes, which I'm figuring out a little at a time and making 
changes to google-c-style.el as I go.

But now I'm stuck because SWIG macros are used in some files.  Here's a 
fragment which is modeled on the kind of thing I'm trying to resolve:

// Example.cc

1  #ifndef GUARD
2  #define GUARD
3
4  #include <something>
5
6  #ifdef SWIG
7
8  %define AMACRO( FIELD1, FIELD2 ) ... macro def ...
9  %enddef
10
11 #define SOMEOTHERMACRO SOMEOTHERDEFINITION
12
13 %define ANOTHERMACRO( ARG )
14    %extend ARG
15    {
16    ...
17    }
18  %enddef
19
20 #endif // SWIG
21
22 class MyClass
23 {
24   ...
25 };
26 ...
27
28 #endif GUARD

Using emacs23, C-c C-s indicates:
 at lines 9 and 10, it's in state func-decl-cont
 at line 11, it's in state ((func-decl-cont)(cpp-macro))
 at line 12, it's back to func-decl-cont
 at line 21, it's now at topmost-intro-cont

And so, emacs wants to indent line 22 because of the state it's in.

Of course, this is because emacs is using what rules it has to interpret what's 
going on. No fault on emacs' part, but I am looking for a solution. (I'm not a 
lisp writer, and haven't yet found anybody who's already dealt with this.)

Any suggestions about how this might be able to be readily handled?

Thanks for your time and expertise.

Blessings,
Doug


reply via email to

[Prev in Thread] Current Thread [Next in Thread]