bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#33840: electric-pair-mode breaks self-insert-command


From: Alan Mackenzie
Subject: bug#33840: electric-pair-mode breaks self-insert-command
Date: Wed, 10 Jul 2019 09:39:56 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Lars.

On Wed, Jul 10, 2019 at 00:39:00 +0200, Lars Ingebrigtsen wrote:
> Alan Mackenzie <address@hidden> writes:

> > In the master branch, put the following into *scratch* and evaluate it:

> >     (defun s-i-c ()
> >       (interactive)
> >       (self-insert-command 1))
> >     (local-set-key "(" 's-i-c))

> > On typing "(", it will be seen that the self-insert-command does its
> > job, correctly entering "(" into *scratch*.

> > Now do M-x electric-pair-mode.

> > If you now type "(", self-insert-command wrongly enters "()" into the
> > buffer.  This is a bug, and is the root cause of bug #33794.

> I must be misunderstanding something -- isn't the entire point of
> electric-pair-mode that it inserts the corresponding parenthesis when
> self-insert-command is called on one of the magical characters?

But the entire point of (self-insert-command 1) is to insert exactly one
copy of what was just typed.  With electric-pair-mode enabled, it no
longer does this; it does something else instead.

self-insert-command is a primitive, and it shouldn't be modified to do
other things.  Instead these other things should be done alongside the
primitive, or after it.

Similarly, you would not modify + such that (+ 2 3) => 6, even if you had
a use case where you wanted this strange arithmetic.

Because of this change to self-insert-command, other uses of it (other
than when bound directly to a key) fail.  This happened in bug #33794
where this change to self-insert-command broke c-electric-brace.  This
has since been worked around by other means.

Being realistic, I now don't really expect this bug to be fixed.  It
would cost too much.  But if you are going to close it, please mark it as
"won't fix" and _not_ "not a bug".

Thanks!

> -- 
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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