all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Josh <josh@foxtail.org>
Cc: 15478@debbugs.gnu.org
Subject: bug#15478: cc-mode does not obey electric-indent-mode
Date: Sat, 5 Oct 2013 16:50:34 +0000	[thread overview]
Message-ID: <20131005165034.GA2943@acm.acm> (raw)
In-Reply-To: <CANdFEAHyA8KE7WKoczyG47_JLxDDw-tw2D8=YCos2ZEZ0J8h6A@mail.gmail.com>

Hi, Josh.

On Fri, Oct 04, 2013 at 02:21:22PM -0700, Josh wrote:
> On Thu, Oct 3, 2013 at 7:32 AM, Stefan Monnier <monnier@iro.umontreal.ca>
> wrote:
> > > What I'm suggesting is some sort of hook so that
> > > electric-indent-mode (and electric-layout-mode, too, I suppose)
> > > invokes the "electric engine" in CC Mode rather than trying to do
> > > the electric indentation itself.
> > Sounds OK.

> Unless I'm misunderstanding, the indentation hook you're describing
> seems very close to `electric-indent-functions':

I'd say it's moderately close rather than very close.  At the moment CC
Mode does its own electric indentation entirely, and I'd like things to
stay that way, so as to minimise incompatibility between versions, to
avoid breaking existing users' setups and so on.

>     electric-indent-functions is a variable defined in `electric.el'.
>     Its value is nil
>       This variable may be risky if used as a file-local variable.
>     Documentation:
>     Special hook run to decide whether to auto-indent.
>     Each function is called with one argument (the inserted char), with
>     point right after that char, and it should return t to cause
> indentation,
>     `no-indent' to prevent indentation or nil to let other functions decide.

> Is there a reason why CC Mode couldn't supply a function here that
> would perform appropriate indentation and then return `no-indent' to
> stop traversal of electric-indent-functions?

It would be a lot of work to rearrange things, and it might leave the
Emacs 24.4 version incompatible with other CC Mode versions.

> Delegation of newline insertion decisions is similarly already supported
> via `electric-layout-rules':

>     electric-layout-rules
>     electric-layout-rules is a variable defined in `electric.el'.
>     Its value is nil
>     Documentation:
>     List of rules saying where to automatically insert newlines.
>     Each rule has the form (CHAR . WHERE) where CHAR is the char
>     that was just inserted and WHERE specifies where to insert newlines
>     and can be: nil, `before', `after', `around', or a function of no
>     arguments that returns one of those symbols.

> If either or both of these delegation mechanisms are insufficient to
> satisfy CC Mode's requirements, it would be interesting to hear how they
> fall short.

CC Mode already does electric actions by other means, and users setups
depend on these.  I don't want to break these existing setups.
Integrating CC Mode's ways with these new mechanisms is a challenge.

> Although I agree with your earlier point that major modes are best
> suited to make decisions about /how/ to perform electric behavior for
> their specific domains, which also seems to be borne out by the existing
> delegation support, I've seen no justification for a major mode deciding
> to disregard (!) my configuration of /whether/ to perform it at all.

Currently, that configuration is done by setting `c-electric-flag',
either in your .emacs or by C-c C-l.  `electric-indent-mode' is the new
kid on the block.  Concrete suggestions for integrating `c-electric-flag'
and `electric-indent-mode' haven't been copious up till now.  I've one or
two ideas myself, but it's not trivial.

> I read the electric-*-mode docstrings describing the exact behavior in
> question and I disabled it.  That should be the end of the story.

Yes.  But there's a difference between you disabling it and merely using
the default value.  Since the current default is already nil, it's not
clear what you mean by "disabling" it.  Perhaps there need to be three
values here, 'default, t and nil.  It's also still up for discussion how
you {en,dis}able electric-indent-mode buffer locally, which is a sensible
thing to want to do.

> Josh

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2013-10-05 16:50 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 [this message]
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
     [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

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

  git send-email \
    --in-reply-to=20131005165034.GA2943@acm.acm \
    --to=acm@muc.de \
    --cc=15478@debbugs.gnu.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.