diff options
| author | Eli Zaretskii | 2018-07-27 13:04:19 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-07-27 13:04:19 +0300 |
| commit | d24c5f26bf6c12bda614f90ba3345d710482005a (patch) | |
| tree | 61d011d84444fad2ab124cc8a05069cb566af70f /src | |
| parent | 71a915153a5b4818f0a3cdebb7a1afb4fe6de374 (diff) | |
| download | emacs-d24c5f26bf6c12bda614f90ba3345d710482005a.tar.gz emacs-d24c5f26bf6c12bda614f90ba3345d710482005a.zip | |
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)
Diffstat (limited to 'src')
| -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. */) | |||
| 3243 | Instead, we announce a single modification for the entire | 3243 | Instead, we announce a single modification for the entire |
| 3244 | modified region. But don't do that if the caller inhibited | 3244 | modified region. But don't do that if the caller inhibited |
| 3245 | modification hooks, because then they don't want that. */ | 3245 | modification hooks, because then they don't want that. */ |
| 3246 | ptrdiff_t from, to; | ||
| 3247 | if (!inhibit_modification_hooks) | 3246 | if (!inhibit_modification_hooks) |
| 3248 | { | 3247 | { |
| 3249 | ptrdiff_t k, l; | 3248 | prepare_to_modify_buffer (BEGV, ZV, NULL); |
| 3250 | |||
| 3251 | /* Find the first character position to be changed. */ | ||
| 3252 | for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++) | ||
| 3253 | ; | ||
| 3254 | from = BEGV + k; | ||
| 3255 | |||
| 3256 | /* Find the last character position to be changed. */ | ||
| 3257 | for (l = size_a; l > k && !bit_is_set (ctx.deletions, l - 1); l--) | ||
| 3258 | ; | ||
| 3259 | to = BEGV + l; | ||
| 3260 | prepare_to_modify_buffer (from, to, NULL); | ||
| 3261 | specbind (Qinhibit_modification_hooks, Qt); | 3249 | specbind (Qinhibit_modification_hooks, Qt); |
| 3262 | modification_hooks_inhibited = true; | 3250 | modification_hooks_inhibited = true; |
| 3263 | } | 3251 | } |
| @@ -3310,9 +3298,8 @@ differences between the two buffers. */) | |||
| 3310 | 3298 | ||
| 3311 | if (modification_hooks_inhibited) | 3299 | if (modification_hooks_inhibited) |
| 3312 | { | 3300 | { |
| 3313 | ptrdiff_t updated_to = to + ZV - BEGV - size_a; | 3301 | signal_after_change (BEGV, size_a, ZV - BEGV); |
| 3314 | signal_after_change (from, to - from, updated_to - from); | 3302 | update_compositions (BEGV, ZV, CHECK_INSIDE); |
| 3315 | update_compositions (from, updated_to, CHECK_INSIDE); | ||
| 3316 | } | 3303 | } |
| 3317 | 3304 | ||
| 3318 | return Qnil; | 3305 | return Qnil; |