unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Josh <josh@foxtail.org>
Cc: gnu-emacs-bug@moderators.isc.org
Subject: bug#15478: cc-mode does not obey electric-indent-mode
Date: Mon, 7 Oct 2013 09:39:00 +0000	[thread overview]
Message-ID: <20131007093859.GA3859__12225.1544300982$1381138998$gmane$org@acm.acm> (raw)
In-Reply-To: <CANdFEAHn6mDv7Lsa+zYs401+J1Fxi91cZOY6Wgg0BZckYTXtjw@mail.gmail.com>

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@gnu.org> wrote:
> > > From: Stefan Monnier <monnier@iro.umontreal.ca>
> > > Date: Sat, 05 Oct 2013 21:10:01 -0400
> > > Cc: gnu-emacs-bug@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).





  reply	other threads:[~2013-10-07  9:39 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28 18:10 bug#15478: cc-mode does not obey electric-indent-mode Stefan Monnier
2013-09-28 20:11 ` Alan Mackenzie
2013-09-29  3:02   ` Stefan Monnier
2013-09-29  9:10     ` Alan Mackenzie
2013-09-30 18:23       ` Stefan Monnier
2013-10-02 20:07         ` Alan Mackenzie
2013-10-03  1:50           ` Stefan Monnier
2013-10-03  2:46             ` Daniel Colascione
2013-10-03  4:10               ` Stefan Monnier
2013-10-03  4:13                 ` Daniel Colascione
2013-10-03  4:50                   ` Stefan Monnier
2013-10-03  5:56                 ` Andreas Röhler
2013-10-03  6:31                   ` Daniel Colascione
2013-10-03 15:52                     ` Eli Zaretskii
2013-10-03 13:15                   ` Dmitry Gutov
2013-10-03 15:04                     ` Stefan Monnier
2013-10-03 17:40                     ` Andreas Röhler
2013-10-03  9:45                 ` Alan Mackenzie
2013-10-03 14:02                   ` Stefan Monnier
2013-10-03 17:45                   ` Andreas Röhler
2013-10-03 10:56             ` Alan Mackenzie
2013-10-03 14:32               ` Stefan Monnier
2013-10-04 21:21                 ` Josh
2013-10-05 16:50                   ` Alan Mackenzie
2013-10-06 17:45                     ` Josh
2013-10-07 13:11                       ` Alan Mackenzie
2013-10-07 21:23                         ` Josh
2013-10-09 17:55                           ` Alan Mackenzie
2013-10-03 11:54 ` Alan Mackenzie
2013-10-03 17:43   ` Andreas Röhler
2013-10-05 17:06 ` Alan Mackenzie
2013-10-06  1:10   ` Stefan Monnier
2013-10-06  2:55     ` Eli Zaretskii
2013-10-06  5:04       ` Josh
2013-10-07  9:39         ` Alan Mackenzie [this message]
     [not found]         ` <20131007093859.GA3859@acm.acm>
2013-10-07 16:05           ` Eli Zaretskii
2013-10-07 21:17             ` Josh
2013-10-08  6:49               ` Eli Zaretskii
2013-10-08 15:59                 ` Josh
2013-10-09 17:32               ` Alan Mackenzie
     [not found]               ` <20131009173206.GA2610@acm.acm>
2013-10-10 19:11                 ` Josh
2013-10-06 17:01       ` Stefan Monnier
2013-10-12 14:54         ` bug#15596: Let's improve the default workings of electric-indent-mode Alan Mackenzie
2013-10-12 16:35           ` Stefan Monnier
2013-10-13 12:36             ` Alan Mackenzie
2013-10-14  2:16               ` Stefan Monnier
2013-10-07 10:30     ` bug#15478: cc-mode does not obey electric-indent-mode Alan Mackenzie
     [not found]     ` <20131007103041.GB3859@acm.acm>
2013-10-07 16:14       ` Stefan Monnier
2013-10-07 20:37         ` Alan Mackenzie
     [not found]         ` <20131007203738.GA3099@acm.acm>
2013-10-07 23:08           ` Stefan Monnier
2013-10-05 17:08 ` Alan Mackenzie
2014-02-17 19:02 ` Alan Mackenzie
     [not found] ` <20140217190249.GB4173@acm.acm>
2014-02-18  0:04   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20131007093859.GA3859__12225.1544300982$1381138998$gmane$org@acm.acm' \
    --to=acm@muc.de \
    --cc=gnu-emacs-bug@moderators.isc.org \
    --cc=josh@foxtail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).