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

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

Re: Unusual C indentation conventions


From: Greg Rowe
Subject: Re: Unusual C indentation conventions
Date: Tue, 29 Mar 2005 07:57:19 -0500
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

no spam wrote:
The code follows an indentation convention that is a bit
unusual for C.  Opening and closing braces are on
a line by themselves and are indented at the same
level as the block they enclose:
    if (someTest)
        {
        doSomething();
        doSomethingElse();
        }
Tab stops are set to 8.  Each block of code is
indented by 4 from the previous block.  (In the
vi editor set ts=8  set sw=4)


The coding style whitesmith is close. C-c . to run c-set-style. Choose whitesmith. You can change the indenting amount in cc-mode by doing M-x set-variable and set c-basic-offset to the number of spaces you desire.

You can change the tab stop width using the tab-width variable. M-x set-variable again.

In your .emacs you might want something like the following to make everything happen automatically:


(add-hook c-mode
        (lambda ()
                (c-set-style "whitesmith")
                (setq c-basic-offset 4)
                (setq tab-width 8)))

Good luck!

Greg

--
Home is where the .bashrc is.


reply via email to

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