diff options
| author | Eli Zaretskii | 2018-06-30 16:50:31 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-30 16:50:31 +0300 |
| commit | ab983522a140187fa2f7bd996c6e3760b0db8d09 (patch) | |
| tree | 26e3809db4db02393ff8d889feef6eeb0e05cb96 /src | |
| parent | 2f149c074d4323e607f4c91b5e6f80c4efd8e09b (diff) | |
| download | emacs-ab983522a140187fa2f7bd996c6e3760b0db8d09.tar.gz emacs-ab983522a140187fa2f7bd996c6e3760b0db8d09.zip | |
Improve on last change in replace-buffer-contents
* src/editfns.c (Freplace_buffer_contents): Call modification
hooks only for the actual region where changes are made.
(Bug#31888)
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/editfns.c b/src/editfns.c index 4d3c838d2ff..90022117140 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3238,9 +3238,21 @@ differences between the two buffers. */) | |||
| 3238 | Instead, we announce a single modification for the entire | 3238 | Instead, we announce a single modification for the entire |
| 3239 | modified region. But don't do that if the caller inhibited | 3239 | modified region. But don't do that if the caller inhibited |
| 3240 | modification hooks, because then they don't want that. */ | 3240 | modification hooks, because then they don't want that. */ |
| 3241 | ptrdiff_t from, to; | ||
| 3241 | if (!inhibit_modification_hooks) | 3242 | if (!inhibit_modification_hooks) |
| 3242 | { | 3243 | { |
| 3243 | prepare_to_modify_buffer (BEGV, ZV, NULL); | 3244 | ptrdiff_t k, l; |
| 3245 | |||
| 3246 | /* Find the first character position to be changed. */ | ||
| 3247 | for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++) | ||
| 3248 | ; | ||
| 3249 | from = BEGV + k; | ||
| 3250 | |||
| 3251 | /* Find the last character position to be changed. */ | ||
| 3252 | for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--) | ||
| 3253 | ; | ||
| 3254 | to = BEGV + l; | ||
| 3255 | prepare_to_modify_buffer (from, to, NULL); | ||
| 3244 | specbind (Qinhibit_modification_hooks, Qt); | 3256 | specbind (Qinhibit_modification_hooks, Qt); |
| 3245 | modification_hooks_inhibited = true; | 3257 | modification_hooks_inhibited = true; |
| 3246 | } | 3258 | } |
| @@ -3293,8 +3305,9 @@ differences between the two buffers. */) | |||
| 3293 | 3305 | ||
| 3294 | if (modification_hooks_inhibited) | 3306 | if (modification_hooks_inhibited) |
| 3295 | { | 3307 | { |
| 3296 | signal_after_change (BEGV, size_a, ZV - BEGV); | 3308 | ptrdiff_t updated_to = to + ZV - BEGV - size_a; |
| 3297 | update_compositions (BEGV, ZV, CHECK_BORDER); | 3309 | signal_after_change (from, to - from, updated_to - from); |
| 3310 | update_compositions (from, updated_to, CHECK_INSIDE); | ||
| 3298 | } | 3311 | } |
| 3299 | 3312 | ||
| 3300 | return Qnil; | 3313 | return Qnil; |