[Top][All Lists]

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

Re: How to indent on LOCK(); macro???

From: Roy Smith
Subject: Re: How to indent on LOCK(); macro???
Date: Wed, 31 Aug 2005 08:31:33 -0400
User-agent: MT-NewsWatcher/3.4 (PPC Mac OS X)

Alan Mackenzie <address@hidden> wrote:
> > How can I convince the indenting engine to treat the LOCK and END_LOCK
> > lines as beginning and ending blocks?
> Only with braces:
> LOCK (MyDataLock) {
>     myData = foo;
> (The semicolon ater END_LOCK will prevent the next statement being
> indented one level too many.)  And if you use auto-newline, you might
> want to extend the functionality of c-snug-do-while so as to indent the
> LOCK construct like a do-while, as above.

Hmmm, I need to think on this, it may be good enough.  The LOCK and 
END_LOCK macros already include the braces (and the trailing semicolon), 
but I can't think of any reason why an extra set of braces or an extra 
semicolon will break anything.  Still, it's not the style used here, and 
(for better or worse), it's difficult (and often a bad idea) to not go 
along with the established style on a big project.

> For a start, the indentation
> engine would have somehow to be told that LOCK should behave like an open
> brace and END_LOCK like a close brace.  Would this be done by you setting
> a configuration variable, or would CC Mode be expected to scan #include
> files, parsing all the macros?

I was thinking (hoping) that there must be some kind of syntax table that I 
could just add an entry to.  From what you're saying, it sounds like there 
isn't.  I certainly agree that parsing all the #include files would be 
impractical (even assuming emacs had enough information to make it 
possible, which it doesn't).

> The other thing is, do you really want your C++ code to look more like
> Pascal?  ;-)

Well, to be honest, I want my C++ code to look more like Python, but I'm 
the new kid on a project with 10 years of history, so I don't always get 
what I want :-(

reply via email to

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