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

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

Re: how to disable C++ namespace indentation


From: Nevo
Subject: Re: how to disable C++ namespace indentation
Date: Thu, 28 Jan 2010 11:53:53 +0800



2010/1/28 Nevo <sakur.deagod@gmail.com>
I think the below is probably what you need. "c-offsets-alist" will be read to add to the base indentation which is default to zero if  I remembered right.

 Sorry,  forget my last words . "c-offsets-alist" will be read to find a match for offset to add to the base indentation which is the last anchor position of the last syntactic element.

;; your coding style
(c-add-style "mycodingstyle"
         '((c-basic-offset . 3)
           (c-comment-only-line-offset . 0)
           (c-hanging-braces-alist . ((substatement-open before after)))
           (c-offsets-alist . ((topmost-intro        . 0)
                   (topmost-intro-cont   . 0)
                   (substatement         . 3)
                   (substatement-open    . 0)
                   (statement-case-open  . 3)
                   (statement-cont       . 3)
                   (access-label         . -3)
                   (inclass              . 3)
                   (inline-open          . 3)
                   (innamespace          . 0)
                   ))))

;; treat all tabs to spaces
(defun my-c-mode-hook ()
  (setq c-basic-offset 4)
  (setq indent-tabs-mode nil)
  (setq show-trailing-whitespace t))
;; c++ uses mycodingstyle
(defun my-c++-mode-hook ()
  (c-set-style "mycodingstyle"))

Nevo

2010/1/28 chun <riverofdreams@gmail.com>

In C++, I want to keep other indentations intact except for namespace
brackets, e.g.
namespace a {
struct A {
 int b;
};

void c {
 int d;
}
}

The above is what I want.  I tried (c-set-offset 'innamespace 0).
However it disables automatic indentation at every line when I hit
return.



reply via email to

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