all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: help-gnu-emacs@gnu.org
Subject: Re: formatting C++ code which includes SWIG macros
Date: Sat, 18 May 2013 16:26:38 +0000 (UTC)	[thread overview]
Message-ID: <kn8a3u$2c4v$1@colin.muc.de> (raw)
In-Reply-To: 14777b2b-e258-48db-a44a-0741e0805be5@googlegroups.com

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).



           reply	other threads:[~2013-05-18 16:26 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <14777b2b-e258-48db-a44a-0741e0805be5@googlegroups.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='kn8a3u$2c4v$1@colin.muc.de' \
    --to=acm@muc.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.