GNU bug report logs - #15478
cc-mode does not obey electric-indent-mode

Previous Next

Packages: emacs, cc-mode;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sat, 28 Sep 2013 18:12:02 UTC

Severity: normal

Found in version 24.3.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #104 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Josh <josh <at> foxtail.org>
Cc: gnu-emacs-bug <at> moderators.isc.org, Eli Zaretskii <eliz <at> gnu.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#15478: cc-mode does not obey electric-indent-mode
Date: Mon, 7 Oct 2013 09:39:00 +0000
Hi, Josh.

On Sat, Oct 05, 2013 at 10:04:00PM -0700, Josh wrote:
> On Sat, Oct 5, 2013 at 7:55 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> > > From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> > > Date: Sat, 05 Oct 2013 21:10:01 -0400
> > > Cc: gnu-emacs-bug <at> moderators.isc.org
> > > For people who don't like electric-indent-mode, CC-mode's
> > > c-electric-flag sucks just as much.
> > Who are they, except for you?  Why don't we hear any complaints about
> > that, except from you?

>     c-electric-flag is a variable defined in `cc-engine.el'.
>     Its value is t

>       Automatically becomes buffer-local when set.

>     Documentation:
>     Not documented as a variable.

> Do you hear many complaints about other undocumented variables?

Here, the variable need only be accessed through the function below.  The
emphasis on this variable is only in discussions like this one, not in
user facilities.

>     C-c C-l runs the command c-toggle-electric-state, which is an
>     interactive compiled Lisp function in `cc-cmds.el'.

>     It is bound to C-c C-l, <menu-bar> <C> <Toggle...> <Electric mode>.

>     (c-toggle-electric-state &optional ARG)

>     Toggle the electric indentation feature.
>     Optional numeric ARG, if supplied, turns on electric indentation when
>     positive, turns it off when negative, and just toggles it when zero or
>     left out.

> This is the command that Alan has claimed solved the problem back in
> 2005 and makes it easy for newbies to easily disable electricity.  I
> don't believe that is so.  Neglecting the fact that newbies are
> unlikely to be familiar with Emacs' "electric" term of art and thus
> unlikely to even make the connection between "c-toggle-electric-state"
> and the behavior they're trying to disable, this docstring makes no
> mention whatsoever of `c-electric-flag', nor does it describe how to
> disable electric behavior permanently.  (One might reasonably assume
> that the global setting would govern here, but as we know it does
> not.)  Perhaps the newbie would have enough Lisp to make the leap from
> that docstring to adding
>   (c-toggle-electric-state -1)
> to her init file, but since that function is not autoloaded it would
> likely only result in a cryptic error message.  She could overcome
> this with an appropriate (require ...) or (eval-after-load ...) form,
> but of what feature?  Should she read the CC Mode source to untangle
> the dependencies in order to find the appropriate top-level feature
> (and maybe go down the rabbit hole of investigating how the unfamiliar
> `cc-require' differs from `require')?  I could only manage to disable
> this feature permanently by reading the source and setq-default'ing
> (because it's not customizable either) an undocumented variable.

Discoverability is a difficulty with lots of things in Emacs.
`c-toggle-electric-state' is fully documented in the CC Mode manual on
the page "Getting Started" (which defines the term "electric
indentation" and indicates how to disable it for all CC Mode buffers),
and there is a link to this from the "FAQ" page.  Read it!

> I suspect that if you don't hear many complaints about this behavior
> it's because the procedure to disable it is beyond the ability of most
> newbies who might wish to do so--perhaps they don't even realize that
> it's possible--and that a good number of them move on to some other
> editor as a result.

When I first started using Emacs (~1996), not only was electric
indentation enabled, but also auto-newline, too.  I found out soon enough
how to disable the latter (which irritated me).

> Others of us read the source code and find the right magic undocumented
> variable to nilify to make editing C stop being annoying without
> complaining to anybody.

Indeed.  Other people ask on help-gnu-emacs.  It's a problem.

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 11 years and 91 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.