Emacs - override indentation

c++, emacs, indentation, namespaces

Solution

Use an an absolute indentation column inside namespace:

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

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

Then use c-set-style to use your own style.

Note that this only works in c++-mode, c-mode doesn't know 'innamespace'.

Problem

I have a multiply nested namespace: ``` namespace first {namespace second {namespace third { // emacs indents three times // I want to intend here } } } ``` so emacs indents to the third position. However I just want a single indentation. Is it possible to accomplish this effect simply?

Original source