Suppress c++ namespace indentation in emacs

c++, emacs, indentation

Solution

(defconst my-cc-style
  '("cc-mode"
    (c-offsets-alist . ((innamespace . [0])))))

(c-add-style "my-cc-mode" my-cc-style)

From Jason Zhang's answer. Works here.

Problem

Possible Duplicate: Emacs - override indentation What I want is for emacs to not indent the code inside a namespace ``` namespace a_namespace{ // no indentation int namespace_global_variable; // no indentation class Class { // comment Class(); //... }; // and so on } ``` When I tried modifying the `innamespace` variable, or using `C-c C-o` to change the indentation at the point of interest, I do not get the desired effect (in fact the latter killed off all of the indentation inside of functions). My indentation configuration looks like this (copied from the Google emacs configuration): ``` (c-offsets-alist . ((arglist-intro vista-c-lineup-expression-plus-4) (func-decl-cont . ++) (member-init-intro . +) (inher-intro . ++) (comment-intro . 0) (arglist-close . c-lineup-arglist) (topmost-intro . 0) (block-open . 0) (inline-open . 0) (substatement-open . 0) (statement-cont . (,(when (fboundp 'c-no-indent-after-java-annotations) 'c-no-indent-after-java-annotations) ,(when (fboundp 'c-lineup-assignments) 'c-lineup-assignments) ++)) (label . /) (case-label . +) (statement-case-open . +) (statement-case-intro . +) ; case w/o { (access-label . /) (innamespace . -)))) ```

Original source

Related problems