help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disabling Electric C Characters?


From: Alan Mackenzie
Subject: Re: Disabling Electric C Characters?
Date: Sat, 27 Oct 2007 09:37:59 +0000
User-agent: Mutt/1.5.9i

Hi, Nathan.

On Sun, Oct 21, 2007 at 08:33:51AM -0700, zenlikethat wrote:

> Hey guys, I'm having some trouble disabling electric characters in C
> mode in my version of Emacs on Ubuntu.

OK, first things first - Have you got a recent enough version of CC
Mode?  The rest of your post suggests you have, but just to make
sure....  Do M-x c-version.  You need 5.31 or higher.  This version of
CC Mode only became part of GNU Emacs at version emacs-22.1.  If
necessary, you can download the current version (5.31.4) from
<http://cc-mode.sourceforge.net/release.php>.

> Every time I type in a curly brace to close off a block of code like a
> function or an if statement, the "}" reindents, completely
> disregarding wherever I may have put it.  I don't like this and am
> trying my hardest to turn it off, but nothing seems to work.

OK.  The thinking behind this feature is that the indentation of a line
can often be calculated only _after_ the line's been typed, not before.
So things like "}" and ";" trigger reindentation.  I'd recommend you to
get to like this if you can.  :-)  However, let's accept that you can't
or won't.

Does C-c C-l (`c-toggle-electric-state') work?

> I've tried putting

> (setq-default c-electric-flag nil) and
> (setq-default c-syntactic-indentation nil)

> in my .emacs file, but to no avail.

> Any suggestions?

(setq-default c-electric-flag nil) should work.  There may be a bug in
CC Mode here.

One other thing to try would be disabling the electricity in a hook.
Try this in your .emacs:

(defun zlt-disable-electricity ()
  (c-toggle-electric-state -1))
(add-hook 'c-mode-common-hook 'zlt-disable-electricity)

> Thanks,

> Nathan

-- 
Alan Mackenzie (Ittersbach, Germany).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]