emacs indentation problem

Posted by Gauthier on Stack Overflow See other posts from Stack Overflow or by Gauthier
Published on 2010-03-17T11:59:17Z Indexed on 2010/03/17 12:01 UTC
Read the original article Hit count: 568

Filed under:
|

I'm really trying to switch to emacs, but learning to setup the environment is a real pain. Everybody says it's worth it, so I just continue.

I want my c code to be implemented that way:

if(asdf)
{
    asdr = 1;
}

Depending on the current standard (I know, don't get me started), could be:

if(asdf) {
    asdr = 1;
}

I can't seem to change the indentation size from 2, it always looks like the GNU standard:

if(asdf)
  {
    asdr = 1;
  }

, which I dislike. Here is what I have put in my .emacs:

; Warn in C for while();, if(x=0), ...
(global-cwarn-mode 1)

; no electric mode in c
(c-toggle-electric-state -1)
; indent the current line only if the cursor is at the beginning of the line
(setq-default c-tab-always-indent nil)
(setq-default c-indent-level 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq-default c-basic-offset 4)
(setq-default c-basic-indent 4)
; These commands I read about on the web, but they don't work?
;(highlight-tabs)
;(highlight-trailing_whitespace)

This did not help, I have still the GNU indent. Anyone?

© Stack Overflow or respective owner

Related posts about emacs

Related posts about indentation