1

I use the default style linux (snippet from here)

;; set indentation style linux for c++
(setq c-default-style "linux"
          c-basic-offset 4)

But I can't get it to work with the style setting which sets zero indent for namespaces (from this question)

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

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

Once I choose my-cc-style with C-c . RET my-cc-mode RET, I get the strange brace indent back which the first setting removes, i.e. like this:

virtual string_type do_falsename() const
    {

Is there a way to keep everything from the default style, and change only the namespace indentation?


Edit: there are a multiple possible solutions to be found here: https://stackoverflow.com/questions/2619853/emacs-override-indentation/22711444#22711444

  • I also had a hard time making this work, so now I just use a hook (added to c-mode-common-hook) that calls (c-set-offset 'innamespace 0). Let me know if I should explain this in more detail. – Constantine Dec 18 '14 at 18:45
1

Defining your style based on linux instead of cc-mode should help.

(defconst my-cc-style
 '("linux" ; this is inheritance from the linux style
   (c-offsets-alist . ((innamespace . [0])))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.