unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Alan Mackenzie <acm@muc.de>
Subject: Re: How to indent on LOCK(); macro???
Date: Wed, 31 Aug 2005 15:20:13 +0000	[thread overview]
Message-ID: <drh4fd.76.ln@acm.acm> (raw)
In-Reply-To: roy-AECF19.08313331082005@reader2.panix.com

Roy Smith <roy@panix.com> wrote on Wed, 31 Aug 2005 08:31:33 -0400:
> 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.

It can't break anything.  The contents of a brace pair are a compound
statement, i.e. syntactically seen, just another statement.

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

It's _always_ a bad idea.  ;-(  (From somebody who's been edged out of
projects more than once for questioning the way things are done.)

Er, can I retract the answer I gave on my last post, please?  You sound
like the sort of guy who can write Elisp.  There is a hook called
`c-special-indent-hook' called after each line has been indented.  You
could put a function onto it that would check if the previous line was a
"LOCK", or the current line is an "END_LOCK", and if so give the line one
more/one less level of indentation.  That hook is described in the CC
Manual on page "Other Special Indentation".

And if you're not a Lisp hacker (or can't be bothered), say so, and I'll
throw some code together for you.

[ .... ]

>> 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 :-(

Oh, _that_ sort of project.  ;-(

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

  reply	other threads:[~2005-08-31 15:20 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
2005-08-31 15:20     ` Alan Mackenzie [this message]
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=drh4fd.76.ln@acm.acm \
    --to=acm@muc.de \
    /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).