From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Denis Bueno Newsgroups: gmane.emacs.help Subject: Re: How to indent on LOCK(); macro??? Date: Tue, 30 Aug 2005 17:21:57 -0400 Message-ID: <7E61B3B8-2F39-47D7-B66A-94A3C7C3C255@gmail.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v734) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1125437236 5376 80.91.229.2 (30 Aug 2005 21:27:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2005 21:27:16 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 30 23:27:13 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EADcl-0006Tz-TJ for geh-help-gnu-emacs@m.gmane.org; Tue, 30 Aug 2005 23:26:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EADgu-00049l-W7 for geh-help-gnu-emacs@m.gmane.org; Tue, 30 Aug 2005 17:30:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EADen-00035V-OK for help-gnu-emacs@gnu.org; Tue, 30 Aug 2005 17:28:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EADef-00031B-PG for help-gnu-emacs@gnu.org; Tue, 30 Aug 2005 17:28:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EADee-00030I-M3 for help-gnu-emacs@gnu.org; Tue, 30 Aug 2005 17:28:28 -0400 Original-Received: from [64.233.184.195] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EADb2-0002Le-Fl for help-gnu-emacs@gnu.org; Tue, 30 Aug 2005 17:24:44 -0400 Original-Received: by wproxy.gmail.com with SMTP id i5so717164wra for ; Tue, 30 Aug 2005 14:22:10 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=LH+wyEcGbPPHt+S9n05upoj4taXghZyZ73Lfdo28xO6FHzC5AwlhkN+yCBhwjN3PZ9JRNMXVYpbHEvYUI0mtvhmNNUZzEd6WZow+46mvWWO0zf2cjGVacvwJGQHshXYasFY1lb0Xj24naFbNi9MzG9o5Zpv5mx7yUsl7sFOpzKw= Original-Received: by 10.54.81.10 with SMTP id e10mr191033wrb; Tue, 30 Aug 2005 14:22:10 -0700 (PDT) Original-Received: from ?192.168.10.213? ( [130.207.197.56]) by mx.gmail.com with ESMTP id 13sm11721433wrl.2005.08.30.14.22.10; Tue, 30 Aug 2005 14:22:10 -0700 (PDT) In-Reply-To: Original-To: Roy Smith X-Mailer: Apple Mail (2.734) 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:29106 Archived-At: On 30 Aug 2005, at 16.51, Roy Smith wrote: > I'm working on a project which uses a LOCK/END_LOCK macro pair for > mutex locking in C++ source files. A typical section of code would > look like: > > LOCK (myDataLock) > myData = foo; > END_LOCK > > How can I convince the indenting engine to treat the LOCK and END_LOCK > lines as beginning and ending blocks? If you wrote the macro in a certain way, you can use braces in your source code (thus obviating your problem): #define WITH_MUTEX_LOCK (l) \ for (int WITH_MUTEX_LOCK_ret = (0 == pthread_mutex_lock (l)); \ WITH_MUTEX_LOCK_ret; \ WITH_MUTEX_LOCK_ret = 0, (void) pthread_mutex_unlock (l)) \ That's at least one solution (perhaps not the best). Then you would write: WITH_MUTEX_LOCK (myDataLock) { myData = foo; } -Denis