[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Customizing C-mode indentation

From: John Mastro
Subject: Customizing C-mode indentation
Date: Wed, 19 Oct 2016 11:42:26 -0700

Hello Emacsers,

I have a question about customizing c-mode's indention, specifically
regarding teaching c-mode about loop macros. I have some C code that
defines a preprocessor macro like:

#define iter_each(iter, v) (void * v; iter_next((iter), v); )

An example use would be:

struct iter it;
iter_init(&it, data);

for iter_each(&it, p) {
    /* ... */

However, because the `iter_each' hides the fact that this is a `for'
loop, c-mode indents it like this:

for iter_each(&it, p) {
        /* ... */

What's the best way to teach c-mode the correct way to indent this
construct? So far what I've found is `c-special-indent-hook', which
works, but I'm wondering if there's a better way I haven't found (e.g.
by customizing a regexp, which would be easier to stick in a



reply via email to

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