From: Roy Smith <roy@panix.com>
Subject: Re: How to indent on LOCK(); macro???
Date: Wed, 31 Aug 2005 08:31:33 -0400 [thread overview]
Message-ID: <roy-AECF19.08313331082005@reader2.panix.com> (raw)
In-Reply-To: 6mo3fd.46.ln@acm.acm
Alan Mackenzie <acm@muc.de> 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;
> } END_LOCK;
>
> (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 :-(
next prev parent reply other threads:[~2005-08-31 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-30 20:51 How to indent on LOCK(); macro??? Roy Smith
2005-08-30 21:21 ` Denis Bueno
2005-08-30 21:27 ` Roy Smith
2005-08-31 8:10 ` Alan Mackenzie
2005-08-31 12:31 ` Roy Smith [this message]
2005-08-31 15:20 ` Alan Mackenzie
2005-08-31 23:50 ` Roy Smith
2005-09-01 16:28 ` Alan Mackenzie
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=roy-AECF19.08313331082005@reader2.panix.com \
--to=roy@panix.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).