Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode

From: Alan Mackenzie <[email-masked]>
Date: Sat, 22 Dec 2018 22:15:40 +0000

Hello, Beatrix and João.

On Sat, Dec 22, 2018 at 21:19:22 +0000, João Távora wrote:
> Beatrix Klebe <[email-masked]> writes:

> > Well, in that case, I am flattered that my opinion is given much
> > weight in this.

> It's supposed to work like that everyday in the Emacs bug tracker.  If
> it flatters you, so much the better :-)

> > Things such as c-toggle-auto-newline, for example, almost seem in this
> > case that they might be better delegated to electric-layout-mode, with
> > cc-mode specifying different electric-layout constraints for its
> > different formatting styles. It seems this is close to what João was
> > suggesting?

This is what I oppose.  Given how well CC Mode's auto-newline works,
such a change would almost certainly be a negative step in quality,
portability, and would be a lot of unrewarding work to do.  CC Mode
isn't broken, here.  It doesn't need fixing, here.

> Yes, that is precisely what I am suggesting.  I am happy that this point
> made it across.

> Though there is not any need to give up on c-toggle-auto-newline if you
> don't use electric-pair-mode, or if you use some other tool like
> smartparens, or perhaps even my older tool autopair.el (tho those tools
> might have other drawbacks that I don't known)

If electric-pair-mode was fixed, it would work perfectly well with CC
Mode.

> > And I suspect what Alan disagrees with? I apologize for any
> > misunderstanding.

One of the things, yes.  CC Mode has, for years, been under constant
attack from people who want to make Emacs major modes work only the way
they think modes should.  CC Mode works differently, for good reasons.
To adapt CC Mode the way these people want would have significant
disadvantages, including some lost functionality.

Right now, João's direction of travel seems to be to cement
electric-pair-mode's unusability in modes like CC Mode, of which there
are quite a few.  I hope I've misunderstood this and I'm mistaken.

> Yes, Alan disagrees with this.  In his view, electric- modes are abusing
> the semantics of post-self-insert-hook.  Well, at least in my view of
> his views :-)

Please don't misrepresent me like that.  The point is that the
electric-... modes abuse not so much the post-self-insert-hook (although
they do), but they totally break self-insert-command.  You have had
several hours to contest this, but by your silence appear to have
accepted it.

electric-pair-mode breaks self-insert-command.

self-insert-command is (or was) a general purpose command for inserting
typed characters into a buffer.  With electric-pair-mode enabled, it
ceases to be general purpose, being usable only in contexts blessed by
the electric-... functionality.  This is why CC Mode's auto-newline
broke.  It will stay broken until electric-pair-mode's breaking of that
function gets fixed.

> João

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).