1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-06 11:55:48 +00:00

Fix calls to buffer modification hooks from replace-buffer-contents

* src/editfns.c (Freplace_buffer_contents): Don't call buffer
modification hooks if nothing was deleted/inserted.  (Bug#32237)
This commit is contained in:
Eli Zaretskii 2018-07-21 21:05:52 +03:00
parent cc4ceed18d
commit 671dc5a51e

View File

@ -3254,10 +3254,12 @@ differences between the two buffers. */)
from = BEGV + k; from = BEGV + k;
/* Find the last character position to be changed. */ /* Find the last character position to be changed. */
for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--) for (l = size_a; l > k && !bit_is_set (ctx.deletions, l - 1); l--)
; ;
to = BEGV + l; to = BEGV + l;
prepare_to_modify_buffer (from, to, NULL); /* If k >= l, it means nothing needs to be deleted. */
if (k < l)
prepare_to_modify_buffer (from, to, NULL);
specbind (Qinhibit_modification_hooks, Qt); specbind (Qinhibit_modification_hooks, Qt);
modification_hooks_inhibited = true; modification_hooks_inhibited = true;
} }
@ -3308,11 +3310,16 @@ differences between the two buffers. */)
SAFE_FREE (); SAFE_FREE ();
rbc_quitcounter = 0; rbc_quitcounter = 0;
if (modification_hooks_inhibited) if (modification_hooks_inhibited && from <= to)
{ {
ptrdiff_t updated_to = to + ZV - BEGV - size_a; ptrdiff_t updated_to = to + ZV - BEGV - size_a;
signal_after_change (from, to - from, updated_to - from); /* Only call after-change-functions if something was actually
update_compositions (from, updated_to, CHECK_INSIDE); inserted. */
if (from < updated_to)
{
signal_after_change (from, to - from, updated_to - from);
update_compositions (from, updated_to, CHECK_INSIDE);
}
} }
return Qnil; return Qnil;