emacs and C++ { } indenting

B North bnorth at mindspring.com
Wed Feb 25 15:09:21 EST 2004


Mike Small has already pointed you to the appropriate
Emacs doc. But since I went through the same quest a
couple of years ago, here's what I ended up with
in my .emacs:

(defun my-c-mode-common-hook ()
  ;; default gnu style is mostly OK
  (c-set-style "gnu")
  ;; but some things just annoy me
  (c-set-offset 'substatement-open '0)  
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

The "gnu" style does functions the way you want, but
indents if/while/for bodies. The second call above fixes that.

Ben




More information about the Discuss mailing list