help-gnu-emacs
[Top][All Lists]
Advanced

[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: Tue, 30 Aug 2005 17:27:24 -0400
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Denis Bueno wrote:

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

Thanks, but unfortunately, the macro pre-dates me and isn't going to change. I must live with what I've been given.





reply via email to

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