aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2018-07-21 21:05:52 +0300
committerEli Zaretskii2018-07-21 21:05:52 +0300
commit671dc5a51edfb9aaea943e144997e7c1297f56fb (patch)
treea864118e278e1e80b7852fe95926abc688da3c09 /src
parentcc4ceed18d51047b390288d2d0a584e678423517 (diff)
downloademacs-671dc5a51edfb9aaea943e144997e7c1297f56fb.tar.gz
emacs-671dc5a51edfb9aaea943e144997e7c1297f56fb.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/editfns.c b/src/editfns.c
index d1a6bfbbb1b..cf596aec37c 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3254,10 +3254,12 @@ differences between the two buffers. */)
3254 from = BEGV + k; 3254 from = BEGV + k;
3255 3255
3256 /* Find the last character position to be changed. */ 3256 /* Find the last character position to be changed. */
3257 for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--) 3257 for (l = size_a; l > k && !bit_is_set (ctx.deletions, l - 1); l--)
3258 ; 3258 ;
3259 to = BEGV + l; 3259 to = BEGV + l;
3260 prepare_to_modify_buffer (from, to, NULL); 3260 /* If k >= l, it means nothing needs to be deleted. */
3261 if (k < l)
3262 prepare_to_modify_buffer (from, to, NULL);
3261 specbind (Qinhibit_modification_hooks, Qt); 3263 specbind (Qinhibit_modification_hooks, Qt);
3262 modification_hooks_inhibited = true; 3264 modification_hooks_inhibited = true;
3263 } 3265 }
@@ -3308,11 +3310,16 @@ differences between the two buffers. */)
3308 SAFE_FREE (); 3310 SAFE_FREE ();
3309 rbc_quitcounter = 0; 3311 rbc_quitcounter = 0;
3310 3312
3311 if (modification_hooks_inhibited) 3313 if (modification_hooks_inhibited && from <= to)
3312 { 3314 {
3313 ptrdiff_t updated_to = to + ZV - BEGV - size_a; 3315 ptrdiff_t updated_to = to + ZV - BEGV - size_a;
3314 signal_after_change (from, to - from, updated_to - from); 3316 /* Only call after-change-functions if something was actually
3315 update_compositions (from, updated_to, CHECK_INSIDE); 3317 inserted. */
3318 if (from < updated_to)
3319 {
3320 signal_after_change (from, to - from, updated_to - from);
3321 update_compositions (from, updated_to, CHECK_INSIDE);
3322 }
3316 } 3323 }
3317 3324
3318 return Qnil; 3325 return Qnil;