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: How to indent on LOCK(); macro??? Date: Wed, 31 Aug 2005 15:20:13 +0000 Organization: muc.de e.V. -- private internet access Message-ID: References: <6mo3fd.46.ln@acm.acm> NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1125504067 22091 80.91.229.2 (31 Aug 2005 16:01:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 31 Aug 2005 16:01:07 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 31 18:01:05 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EAUxr-0005cm-4k for geh-help-gnu-emacs@m.gmane.org; Wed, 31 Aug 2005 17:57:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EAV22-0002XW-JQ for geh-help-gnu-emacs@m.gmane.org; Wed, 31 Aug 2005 12:01:46 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1125503092 97214 193.149.49.134 (31 Aug 2005 15:44:52 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 31 Aug 2005 15:44:52 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:133585 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:29122 Archived-At: Roy Smith wrote on Wed, 31 Aug 2005 08:31:33 -0400: > Alan Mackenzie 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").