[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 671dc5a: Fix calls to buffer modification hooks f
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 671dc5a: Fix calls to buffer modification hooks from replace-buffer-contents |
Date: |
Sat, 21 Jul 2018 14:06:17 -0400 (EDT) |
branch: emacs-26
commit 671dc5a51edfb9aaea943e144997e7c1297f56fb
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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)
---
src/editfns.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index d1a6bfb..cf596ae 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3254,10 +3254,12 @@ differences between the two buffers. */)
from = BEGV + k;
/* 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;
- 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);
modification_hooks_inhibited = true;
}
@@ -3308,11 +3310,16 @@ differences between the two buffers. */)
SAFE_FREE ();
rbc_quitcounter = 0;
- if (modification_hooks_inhibited)
+ if (modification_hooks_inhibited && from <= to)
{
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);
+ /* Only call after-change-functions if something was actually
+ inserted. */
+ if (from < updated_to)
+ {
+ signal_after_change (from, to - from, updated_to - from);
+ update_compositions (from, updated_to, CHECK_INSIDE);
+ }
}
return Qnil;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 671dc5a: Fix calls to buffer modification hooks from replace-buffer-contents,
Eli Zaretskii <=