unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39680: 27.0.60; electric-pair-mode broken by undo
@ 2020-02-19 18:34 Kévin Le Gouguec
  2020-02-25 19:34 ` Alan Mackenzie
  0 siblings, 1 reply; 10+ messages in thread
From: Kévin Le Gouguec @ 2020-02-19 18:34 UTC (permalink / raw)
  To: 39680; +Cc: Stefan Monnier

Hello,

Commit e66d5a1c45 (2019-02-19T00:00:44Z!monnier@iro.umontreal.ca) might
have introduced a bug.  From emacs -Q:

1. C-x b foo RET
2. M-x electric-pair-mode RET
3. (
    - A closing parenthesis has been inserted.
4. C-b C-f
    - This is to break undo grouping.
5. a
6. C-_
7. (

In Emacs 26.3, buffer foo contains "(())" and point is after the
innermost opening bracket.

In Emacs 27, buffer foo contains "()" and point is after the closing
bracket.  The *Messages* buffer shows:

> cancel-change-group: Undoing to some unrelated state

NB: this can be reproduced with other electric-pair characters, e.g. ".
I found the bug in a Python buffer trying to write a tuple of strings: I
opened a parenthesis, forgot to add quotes, wrote a string, hit undo,
tried to insert a single quote… and got moved past the end parenthesis
instead.

I tried to write a non-regression test; unfortunately what I came up
with does not catch this bug reliably:

(ert-deftest electric-pair-undo-unrelated-state ()
  (with-temp-buffer
    (buffer-enable-undo)
    (electric-pair-mode)
    (let ((last-command-event ?\())
      (self-insert-command 1))
    (undo-boundary)
    (insert "hi there")
    (undo)
    (let ((last-command-event ?\())
      (self-insert-command 1))))

C-x C-e'ing the (with-temp-buffer …) form only triggers the error once
every two evaluations, for some reason.


Thank you for your time.


In GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.24.13, cairo version 1.16.0)
 of 2020-02-19 built on my-little-tumbleweed
Repository revision: e1e1bd8f85c53fea9f61b6ec99b461ddd93461b9
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12007000
System Description: openSUSE Tumbleweed

Configured using:
 'configure --with-xwidgets --with-cairo'





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-19 23:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-19 18:34 bug#39680: 27.0.60; electric-pair-mode broken by undo Kévin Le Gouguec
2020-02-25 19:34 ` Alan Mackenzie
2020-03-09 18:26   ` Stefan Monnier
2020-03-10  6:45     ` Kévin Le Gouguec
2020-03-11 15:31       ` Stefan Monnier
2020-03-11 16:20         ` Eli Zaretskii
2020-03-12 14:04           ` Stefan Monnier
     [not found]       ` <87d078ajzs.fsf@gmail.com>
     [not found]         ` <87blmstg0v.fsf@gmail.com>
     [not found]           ` <87blms6ww9.fsf@gmail.com>
     [not found]             ` <877dxgtae9.fsf@gmail.com>
2020-05-19 22:05               ` bug#39680: Test case Kévin Le Gouguec
2020-05-19 22:26                 ` Kévin Le Gouguec
2020-05-19 23:17                 ` João Távora

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).