4

Emacs reindents the current line whenever I type certain things, like ";" or "//". This is pretty annoying, since there are a whole lot of places where it isn't smart enough to indent correctly.

How do I disable this feature? I still want to be able to indent the line with TAB, but I don't want any source code I type to cause it to reindent.

(I'm using Dylan Moonfire's C# mode, but this probably applies to any cc-mode.)

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
Ken
  • 5,337
  • 3
  • 28
  • 19
  • When it works, it's an awesome feature. As you've experienced, it's a ridiculous unbelievably difficult feature to nail down. http://stackoverflow.com/questions/1318976/smart-indent-algorithm-documentation – Sam Harwell Aug 26 '09 at 06:24
  • I don't think it's "unbelievably difficult". csharp-mode.el was last updated in 2007, when C# 2.0 was the latest version. I think the only hard part is finding an elisp hacker who wants to deal with maintaining a C# mode. :-) – Ken Aug 26 '09 at 17:11

2 Answers2

9

Try running c-toggle-electric-state to turn off the electric action of these characters.

You can do this as part of a c-mode-common-hook, or toggle the state manually by hitting C-c C-l.

Blair Conrad
  • 233,004
  • 25
  • 132
  • 111
1

most likely caused by the inline-and-indent 'feature' of c-mode and derivatives. emacswiki has several solutions.

Steen
  • 6,573
  • 3
  • 39
  • 56