[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#39680: 27.0.60; electric-pair-mode broken by undo
From: |
Stefan Monnier |
Subject: |
bug#39680: 27.0.60; electric-pair-mode broken by undo |
Date: |
Wed, 11 Mar 2020 11:31:45 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> I think we need something like the patch below (not really tested yet).
>> WDYT?
>
> FWIW, I applied it and AFAICT I can't reproduce the issue.
Thanks. I think the patch wasn't quite right and was overly
complicated: `undo` is already responsible for dealing with the
freshness of `pending-undo-list`. So I think the better patch is the
one below.
Eli, is the patch below OK for `emacs-27`?
Stefan
[ BTW, I accidentally installed the previous patch on `master`, and I'm
waiting for "the right solution" to clean up. ]
diff --git a/lisp/subr.el b/lisp/subr.el
index 5b94343e499..4c69c9dd044 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2964,13 +2964,18 @@ cancel-change-group
;; the body of `atomic-change-group' all changes can be undone.
(widen)
(let ((old-car (car-safe elt))
- (old-cdr (cdr-safe elt)))
+ (old-cdr (cdr-safe elt))
+ ;; Use `pending-undo-list' temporarily since `undo-more' needs
+ ;; it, but restore it afterwards so as not to mess with an
+ ;; ongoing sequence of `undo's.
+ (pending-undo-list
+ ;; Use `buffer-undo-list' unconditionally (bug#39680).
+ buffer-undo-list))
(unwind-protect
(progn
;; Temporarily truncate the undo log at ELT.
(when (consp elt)
(setcar elt nil) (setcdr elt nil))
- (unless (eq last-command 'undo) (undo-start))
;; Make sure there's no confusion.
(when (and (consp elt) (not (eq elt (last pending-undo-list))))
(error "Undoing to some unrelated state"))