mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
* lisp/elec-pair.el: Do modify+undo more carefully
(electric-pair-inhibit-if-helps-balance): Use the undo system instead of undoing by hand.
This commit is contained in:
parent
a812ed215c
commit
e66d5a1c45
1 changed files with 19 additions and 14 deletions
|
|
@ -429,9 +429,15 @@ some list calculations, finally restoring the situation as if nothing
|
||||||
happened."
|
happened."
|
||||||
(pcase (electric-pair-syntax-info char)
|
(pcase (electric-pair-syntax-info char)
|
||||||
(`(,syntax ,pair ,_ ,s-or-c)
|
(`(,syntax ,pair ,_ ,s-or-c)
|
||||||
(unwind-protect
|
(catch 'done
|
||||||
(progn
|
;; FIXME: modify+undo is *very* tricky business. We used to
|
||||||
|
;; use `delete-char' followed by `insert', but this changed the
|
||||||
|
;; 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)
|
(delete-char -1)
|
||||||
|
(throw
|
||||||
|
'done
|
||||||
(cond ((eq ?\( syntax)
|
(cond ((eq ?\( syntax)
|
||||||
(let* ((pair-data
|
(let* ((pair-data
|
||||||
(electric-pair--balance-info 1 s-or-c))
|
(electric-pair--balance-info 1 s-or-c))
|
||||||
|
|
@ -441,8 +447,7 @@ happened."
|
||||||
(t
|
(t
|
||||||
(eq (cdr outermost) pair)))))
|
(eq (cdr outermost) pair)))))
|
||||||
((eq syntax ?\")
|
((eq syntax ?\")
|
||||||
(electric-pair--unbalanced-strings-p char))))
|
(electric-pair--unbalanced-strings-p char)))))))))
|
||||||
(insert char)))))
|
|
||||||
|
|
||||||
(defun electric-pair-skip-if-helps-balance (char)
|
(defun electric-pair-skip-if-helps-balance (char)
|
||||||
"Return non-nil if skipping CHAR would benefit parentheses' balance.
|
"Return non-nil if skipping CHAR would benefit parentheses' balance.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue