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

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

c indentation problem


From: jodocus
Subject: c indentation problem
Date: Mon, 28 Aug 2006 11:28:53 +0200

Hi, 

I have the following problem: for a project I am working on, the C code at
the start of a function is indented as follows:

void func ( arglist a )
{
int somevar;
char someothervar;

    do_something();
    if( cond )
    {
        action;
    }
}

As you can see, the declaration of variables at the start of the function
body is not indented. Then, there is an empty line, and the rest of the
function (the "real" body containing statements that are not variable
declarations) is indented. How do I get emacs to understand this?

I already have the following code in my .emacs, which works pretty well,
except for the above problem.

(defconst my-c-style
  '((c-basic-offset . 4) 
        (c-comment-only-line-offset . 0)
    (c-offsets-alist (statement-block-intro . +) 
;                                        (knr-argdecl-intro . 0) 
;                                        (knr-argdecl . 0)
;                                        (topmost-intro . 0)
;                                        (topmost-intro-cont . 0)
                                         (substatement-open . 0) 
                                         (label . 0) 
                                         (case-label . +)
                                         (statement-cont . +) 
                                         (inline-open . 0) 
                                         (inexpr-class . 0))
        )
  "MY style")


reply via email to

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