Subject: bug#15478: cc-mode does not obey electric-indent-mode

From: Alan Mackenzie <[email-masked]>
Date: Sun, 29 Sep 2013 09:10:17 +0000

'morning, Stefan.

On Sat, Sep 28, 2013 at 11:02:39PM -0400, Stefan Monnier wrote:
> > In particular, the electricity MUST be enabled by default in CC Mode,
> > otherwise automatic indentation won't work.  For example, after typing "}"
> > at the end of an otherwise blank line, the "}" typically needs to be
> > indented several spaces outwards.

> I don't see in which way this is different for cc-mode than for any
> other major mode.

I'm not familiar enough with these other modes to be able to say.  But
what exactly are you saying here?  Even if CC Mode is not different from
the other modes, that doesn't change the fact that electricity must be
enabled by default in CC Mode.

> > electric-indent-mode is not buffer local; c-electric-flag is.

> Indeed, currently it can only be enabled globally.  But it can be
> disabled per-buffer.
> I haven't heard any complaint about it from users yet.

> > There is a key binding to toggle c-electric-flag, namely C-c C-l.

> I'm not sure that would prevent cc-mode from obeying
> electric-indent-mode.

Perhaps not, but there is a good deal of thinking and scheming needed
before this can be done.  For CC Mode simply to `and' in the variable
electric-indent-mode when testing c-electric-flag would cause breakage,
confusion and bug reports.  Or perhaps should CC Mode set a buffer-local
copy of e-i-m to t at initialisation?  Should C-c C-l be extended also
to toggle e-i-m?  And so on....

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).