From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: formatting C++ code which includes SWIG macros Date: Sat, 18 May 2013 16:26:38 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: <14777b2b-e258-48db-a44a-0741e0805be5@googlegroups.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1368896713 13912 80.91.229.3 (18 May 2013 17:05:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 May 2013 17:05:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 18 19:05:13 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UdkZE-0002Nv-Fx for geh-help-gnu-emacs@m.gmane.org; Sat, 18 May 2013 19:05:12 +0200 Original-Received: from localhost ([::1]:50005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdkZD-0005WQ-O6 for geh-help-gnu-emacs@m.gmane.org; Sat, 18 May 2013 13:05:11 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-NNTP-Posting-Host: news.muc.de Original-X-Trace: colin.muc.de 1368894398 77983 193.149.48.2 (18 May 2013 16:26:38 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Sat, 18 May 2013 16:26:38 +0000 (UTC) User-Agent: tin/1.9.6-20101126 ("Burnside") (UNIX) (FreeBSD/8.4-PRERELEASE (amd64)) Original-Xref: usenet.stanford.edu gnu.emacs.help:198638 X-Mailman-Approved-At: Sat, 18 May 2013 13:05:02 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90903 Archived-At: Hi, Doug. Douglas Meyer 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).