diff options
author | Eli Zaretskii <eliz@gnu.org> | 2018-07-27 13:04:19 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2018-07-27 13:04:19 +0300 |
commit | d24c5f26bf6c12bda614f90ba3345d710482005a (patch) | |
tree | 61d011d84444fad2ab124cc8a05069cb566af70f | |
parent | 71a915153a5b4818f0a3cdebb7a1afb4fe6de374 (diff) | |
download | emacs-d24c5f26bf6c12bda614f90ba3345d710482005a.tar.gz |
Fix calls to modifications hooks in replace-buffer-contents
* src/editfns.c (Freplace_buffer_contents): Call the modification
hooks on the entire region where replacements could have taken
place. The previous attempts of being more accurate just
introduced bugs. (Bug#32278)
-rw-r--r-- | src/editfns.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/editfns.c b/src/editfns.c index a18a71e6d77..a8acff659cd 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3243,21 +3243,9 @@ differences between the two buffers. */) Instead, we announce a single modification for the entire modified region. But don't do that if the caller inhibited modification hooks, because then they don't want that. */ - ptrdiff_t from, to; if (!inhibit_modification_hooks) { - ptrdiff_t k, l; - - /* Find the first character position to be changed. */ - for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++) - ; - from = BEGV + k; - - /* Find the last character position to be changed. */ - for (l = size_a; l > k && !bit_is_set (ctx.deletions, l - 1); l--) - ; - to = BEGV + l; - prepare_to_modify_buffer (from, to, NULL); + prepare_to_modify_buffer (BEGV, ZV, NULL); specbind (Qinhibit_modification_hooks, Qt); modification_hooks_inhibited = true; } @@ -3310,9 +3298,8 @@ differences between the two buffers. */) if (modification_hooks_inhibited) { - ptrdiff_t updated_to = to + ZV - BEGV - size_a; - signal_after_change (from, to - from, updated_to - from); - update_compositions (from, updated_to, CHECK_INSIDE); + signal_after_change (BEGV, size_a, ZV - BEGV); + update_compositions (BEGV, ZV, CHECK_INSIDE); } return Qnil; |