all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: formatting C++ code which includes SWIG macros
       [not found] <14777b2b-e258-48db-a44a-0741e0805be5@googlegroups.com>
@ 2013-05-18 16:26 ` Alan Mackenzie
  0 siblings, 0 replies; only message in thread
From: Alan Mackenzie @ 2013-05-18 16:26 UTC (permalink / raw)
  To: help-gnu-emacs

Hi, Doug.

Douglas Meyer <dbmeyer030@gmail.com> wrote:
> Hi folks,

> I've entered into an existing project that is written in C++.

I think the problem is that it's _not_ C++, rather it's an idiosyncratic
extension, which (ab)uses the modulus operator to introduce a new type of
macro.

> The style is nearly the same as google-c-style.el, and so I'm using
> that with minor changes in emacs 23.1.1.

> The fly in the ointment are SWIG macros used in some C++ files. Since
> emacs apparently knows nothing about SWIG being used in other source
> files, the C++ formatting gets confused. Of course, this is because
> emacs is using what rules it has to interpret the code. No fault on
> emacs' part.

Presumably, there's some sort of preprocessor which converts these SWIG
files to standard C++ before they get to the compiler

> [If you're curious, I've put sketch of the kind of things I'm dealing
> with in the P.S.]

> I'm searching for a solution, and haven't yet found anybody who's
> already dealt with this. Unfortunately, I'm not a lisp writer.

Let me guess a few things about SWIG:
1. All SWIG keywords start with a %.
2. There are several such keywords rather than many.
3. A SWIG construct is always on a line of its own.
4. A SWIG construct is never continued onto a new line by \ (or anything
  else).
5. Standard C++ lines are syntactically independent of SWIG lines.

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

To do this properly would involve extending C++ Mode and this would be an
enormous amount of work.  A more realistic approach might be to treat all
SWIG lines as being terminated by a "virtual semicolon" thus preventing
lines like "class MyClass" as being parsed as the continuation of a SWIG
line.

I could probably manage to do this for you, but first, could you confirm
(or correct) my 5 guesses above, and supply a list of SWIG keywords.

> Thanks for your time and expertise.

No problem!

> Blessings,
> Doug

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-18 16:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <14777b2b-e258-48db-a44a-0741e0805be5@googlegroups.com>
2013-05-18 16:26 ` formatting C++ code which includes SWIG macros Alan Mackenzie

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.