1

I'm an emacs newbie and I've been trying to set up my indent style for cc-mode. I like to write code like this:

if(true)
{
    foo();
    bar();
}

But the default indent style is more like:

if(true)
  {
    foo();
    bar();
  }

It seems the indent style I want is "bsd" while the default is "gnu". I put the following in my init.el file to change the settings:

(setq c-default-style "bsd")
(setq c-basic-indent 4)
(setq c-basic-offset 4)

This changed the offset and the default style, but when I typed some code out, it was still formatted like the gnu style. To clarify, I would type out if(true) [ENTER] { [ENTER] foo(); [ENTER] } and the result would be the gnu style code. I also tried putting this in my init.el, for the same results:

(defun my-c-mode-hook ()
(setq c-basic-offset 4
    c-indent-level 4
    c-default-style "bsd"))
(add-hook 'c-mode-common-hook 'my-c-mode-hook)

I could tell the settings were definitely changed because in the minibuffer I evaluated this expression (message "%s %s %d" c-default-style c-indentation-style c-basic-offset) to get this result: "bsd bsd 4"

I am using graphene. Is it possible that one of its included packages (smartparens or autocomplete maybe) could be interfering with my settings?

  • 1
    It seems that you're doing the right thing. You should ask here: https://github.com/rdallasgray/graphene/issues. Also have a look at https://github.com/technomancy/emacs-starter-kit, to see why pre-packaged starter kits aren't the best way to go. – abo-abo Mar 12 '14 at 07:35
  • See also [this question](http://stackoverflow.com/q/2461962/113848). – legoscia Mar 12 '14 at 10:54

0 Answers0