[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: João Távora
Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode
Date: Sat, 22 Dec 2018 00:45:20 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Hi Alan,

I will be replying to the two emails you sent me in this single message.

Alan Mackenzie <address@hidden> writes:

> No, not at all.  CC Mode has been working for several decades, and works
> well.  electric-pair-mode is the new kid on the block, just a few years
> old, and was apparently hacked together without regard to some well
> established conventions.  It should have provided interfaces to allow
> existing software to connect to it - for example a variable to contain a
> function to insert the electric character, or something like that.
> Maybe.  It should have been considered, but apparently wasn't.

First, I think you'll agree that antiquity is a poor measure of the
merits of software.  Here's a characteristic of electric-pair-mode that
I think is an actual merit: it works for every mode in Emacs..

Also, I don't know if you understand the history of electric-pair-mode.
It has two generations: One, before 24.4, which I believe Stefan wrote,
where it was a simpler mode to automatically insert parenthesis and
quotes as described in electric-pair-pairs.  Then, in 24.4, I borrowed
code from my reasonably popular autopair.el extension and e-p-m became a
mode that automatically infers what characters to pair from the syntax
table of each mode.  Furthermore, in the new version, it also makes
educated guesses about when to pair or when not to pair based, again on
the information collected from the buffer and its syntax table by

The use of post-self-insert-hook was a requirement at the time, since
that is how the pre-24.4 electric-pair-mode, electric-indent-mode and
electric-layout-mode already worked.  I welcomed this requirement, and
it was what encouraged me to kill autopair.el and migrate to the new
framework, since in autopair.el I had to rebind the parenthesis keys,
which is akward (much like c-electric-brace and c-electric-paren are
akward IMO).  This simplified the code tremendously.

So these "well established conventions" are, with all due respect,
nothing more than personal opinions based on a narrow experience with a
subset of modes (maybe "mode" singular), tried and tested as it may be.

If I abandon the post-self-insert-hook convention for e-p-m, I'll
probably be breaking the e-p-m interaction with electric-indent-mode,
electric-layout-mode, etc.  If there are existing problems with these
interactions they should be fixed, but I will not fix e-p-m for
interaction a specific part of cc-mode, unless you provide
retro-compatible fix that guarantees existing behaviour outside cc-mode.

I would rather declare e-p-m incompatible with that part of cc-mode and
invest some time in providing alternatives based on
electric-layout-mode, fixing Beatrix's problem by replacing bits of
cc-mode-specific initialization in her init file with bits that works
for all modes, including cc-mode.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]