[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c99815fffa: combine-change-calls-1: Fix case where `body` also ch
From: |
Stefan Monnier |
Subject: |
master c99815fffa: combine-change-calls-1: Fix case where `body` also changes other bufs |
Date: |
Thu, 15 Sep 2022 16:31:21 -0400 (EDT) |
branch: master
commit c99815fffad7a320c35a516548fd67fedaf0e732
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
combine-change-calls-1: Fix case where `body` also changes other bufs
* lisp/subr.el (combine-change-calls-1): Only set the current buffer's part
of the `*-change-functions` hooks.
---
lisp/subr.el | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 8769fec2b9..bfc2e207b2 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4823,16 +4823,26 @@ the function `undo--wrap-and-run-primitive-undo'."
(let ((undo--combining-change-calls t))
(if (not inhibit-modification-hooks)
(run-hook-with-args 'before-change-functions beg end))
- (let (;; (inhibit-modification-hooks t)
- (before-change-functions
- ;; Ugly Hack: if the body uses syntax-ppss/syntax-propertize
- ;; (e.g. via a regexp-search or sexp-movement triggering
- ;; on-the-fly syntax-propertize), make sure that this gets
- ;; properly refreshed after subsequent changes.
- (if (memq #'syntax-ppss-flush-cache before-change-functions)
- '(syntax-ppss-flush-cache)))
- after-change-functions)
- (setq result (funcall body)))
+ (let ((bcf before-change-functions)
+ (acf after-change-functions)
+ (local-bcf (local-variable-p 'before-change-functions))
+ (local-acf (local-variable-p 'after-change-functions)))
+ (unwind-protect
+ ;; FIXME: WIBNI we could just use `inhibit-modification-hooks'?
+ (progn
+ ;; Ugly Hack: if the body uses syntax-ppss/syntax-propertize
+ ;; (e.g. via a regexp-search or sexp-movement triggering
+ ;; on-the-fly syntax-propertize), make sure that this gets
+ ;; properly refreshed after subsequent changes.
+ (setq-local before-change-functions
+ (if (memq #'syntax-ppss-flush-cache bcf)
+ '(syntax-ppss-flush-cache)))
+ (setq-local after-change-functions nil)
+ (setq result (funcall body)))
+ (if local-bcf (setq before-change-functions bcf)
+ (kill-local-variable 'before-change-functions))
+ (if local-acf (setq after-change-functions acf)
+ (kill-local-variable 'after-change-functions))))
(when (not (eq buffer-undo-list t))
(let ((ap-elt
(list 'apply
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c99815fffa: combine-change-calls-1: Fix case where `body` also changes other bufs,
Stefan Monnier <=