5

I'm using the bsd style of indentation in emacs & I'd like to modify it a bit. The related portion of my .emacs file is below. When I write a function with try catch blocks the braces are indented. I'd like them to not indent similar to a function.

What's it's doing now.

try 
    {
    }
catch 
    {
    }

What I'd like it to do.

try 
{
}
catch 
{
}

.emacs file

(defun my-c-mode-common-hook ()
  ;; my customizations for all of c-mode and related modes
  ;; other customizations can go here
  (setq c-default-style "bsd")
  (setq c-basic-offset 4)
  (setq indent-tabs-mode nil)
  )

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

Any help would be appreciated.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Stephen Burke
  • 882
  • 3
  • 10
  • 25

1 Answers1

7

Go to the line with the indent you'd like to change and press C-c C-o. This runs c-set-offset and defaults to the current line's syntax (in this case substatement-open). '+' means one level of indent, '-' means one level unindent, and '0' means no additional indent. You want 0. To make it permanent, add (c-set-offset 'substatement-open 0) to your hook.

scottfrazer
  • 17,079
  • 4
  • 51
  • 49