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

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

indentation help in C++ mode


From: luca . pamparana
Subject: indentation help in C++ mode
Date: Fri, 3 Apr 2009 11:07:28 -0700 (PDT)
User-agent: G2/1.0

Hello,

I have this problem where the indentation does not work as expected:

So, if I have the following lines of code:

int main()
{
    int x = 10; // this indents fine as expected
    for (int i = 0; i < x; ++i)
        { // I would like this to be under the beginning of previous
statement
             ........
        }
}

As you can see, the indentation for loops etc. does not work as I
would have expected.

The relevant lines in my .emacs file look as follows:

(require 'cc-mode)

(defun my-c++-mode-hook ()
  (setq indent-tabs-mode nil)
  (setq tab-width 4)
  (define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent)
  (define-key c++-mode-map "\C-ce" 'c-comment-edit)
  (setq c++-auto-hungry-initial-state 'none)
  (setq c++-delete-function 'backward-delete-char)
  (setq c++-tab-always-indent nil)
  (setq tab-stop-list '(4 8 12 16))
  (setq c-basic-offset 4)
  (setq c-indent-level 4)
  (setq c-continued-statement-offset 4)
  (setq c++-empty-arglist-indent 4))

Does anyone know how I can change this behaviour??

Many thanks,

Luca


reply via email to

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