Subject: Re: bug#23298: 25.0.92; electric-pair-delete-pair doesn't check if parens are balanced

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 28 Jul 2019 22:07:49 +0200

Mohammed Sadik <[email-masked]> writes:

> When pressing Backspace key, with electric-pair-mode enabled,
> it unconditionally deletes the following char, if its the matching pair.
> Ideally, it may better check if it breaks the equilibrium of
> braces/quotes.
>
> Eg: code: (char-before (point))
>                              |_ point location
> If my point (cursor) is just before the last paren (the cursor is
> blinking on the last paren), and I press backspace until the beginning
> of "point"[0], and then one char back[1], it just deletes the bracket,
> without checking if the parens are balanced.
>
> code:
>         [0] (char-before ()
>                          |_point location
>         [1] (char-before
>                         |_ point location
>
> This could be the case of quotes, braces, etc.

(I'm going through old Emacs bug reports that haven't received any
response.)

Or a simpler example:

(foo ()

If you put point after the next-to-last character, then hitting DEL will
delete the last pair:

(foo 

But...  I don't think this is a bug?  electric-pair-mode doesn't promise
to keep things balanced globally, but delete the matching pair if you
delete an opening parenthesis?  I think.

Does that tally with what everybody else would expect?

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