summaryrefslogtreecommitdiff
path: root/lisp/elec-pair.el
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-06-06 21:00:44 +0800
committerPo Lu <luangruo@yahoo.com>2023-06-06 21:00:44 +0800
commitbf28b019a85fcc4e16bc7ecad6304c30e48a3223 (patch)
tree0fc53c2707e0aab410ef20399fcc2ac1b2b71990 /lisp/elec-pair.el
parent05c2be28a3e97bd920d0bf8c8b59ec682a420cce (diff)
downloademacs-bf28b019a85fcc4e16bc7ecad6304c30e48a3223.tar.gz
Fix problems resulting from modification of the undo list
* doc/lispref/text.texi (Atomic Changes): Describe what not to do inside an atomic change group. * lisp/elec-pair.el (electric-pair-inhibit-if-helps-balance): Don't call `delete-char'; that edits the undo list by removing boundary markers. * lisp/subr.el (atomic-change-group, prepare-change-group): Warn against modifying the undo list inside.
Diffstat (limited to 'lisp/elec-pair.el')
-rw-r--r--lisp/elec-pair.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index b894965eae4..416c95e7a34 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -439,7 +439,9 @@ happened."
;; position some markers. The real fix would be to compute the
;; result without having to modify the buffer at all.
(atomic-change-group
- (delete-char -1)
+ ;; Don't use `delete-char'; that may modify the head of the
+ ;; undo list.
+ (delete-region (point) (1- (point)))
(throw
'done
(cond ((eq ?\( syntax)