aboutsummaryrefslogtreecommitdiffstats
path: root/src/insdel.c
diff options
context:
space:
mode:
authorNoam Postavsky2016-07-20 20:15:14 -0400
committerNoam Postavsky2016-07-22 23:55:23 -0400
commit66f95e0dabf750e9d2eff59b2bb6e593618cd48a (patch)
treea8cd27828bfef2459b70e446cdf1de346327fc3e /src/insdel.c
parent52cf0d5d98c51c3591ca5d376fd4e85cd9b72d7f (diff)
downloademacs-66f95e0dabf750e9d2eff59b2bb6e593618cd48a.tar.gz
emacs-66f95e0dabf750e9d2eff59b2bb6e593618cd48a.zip
Adjust match data before calling after-change-funs
It's important to adjust the match data in between calling before-change-functions and after-change-functions, so that buffer change hooks will always see match-data consistent with buffer content. (Bug #23917) * src/insdel.c (replace_range): Add new parameter ADJUST_MATCH_DATA, if true call update_search_regs. Update all callers (except Freplace_match) to pass 0 for the new parameter. * src/search.c (update_search_regs): New function, extracted from Freplace_match. (Freplace_match): Remove match data adjustment code, pass 1 for ADJUST_MATCH_DATA to replace_range instead.
Diffstat (limited to 'src/insdel.c')
-rw-r--r--src/insdel.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 4ad1074f5f7..fc3f19fd581 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1268,7 +1268,9 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte,
1268/* Replace the text from character positions FROM to TO with NEW, 1268/* Replace the text from character positions FROM to TO with NEW,
1269 If PREPARE, call prepare_to_modify_buffer. 1269 If PREPARE, call prepare_to_modify_buffer.
1270 If INHERIT, the newly inserted text should inherit text properties 1270 If INHERIT, the newly inserted text should inherit text properties
1271 from the surrounding non-deleted text. */ 1271 from the surrounding non-deleted text.
1272 If ADJUST_MATCH_DATA, then adjust the match data before calling
1273 signal_after_change. */
1272 1274
1273/* Note that this does not yet handle markers quite right. 1275/* Note that this does not yet handle markers quite right.
1274 Also it needs to record a single undo-entry that does a replacement 1276 Also it needs to record a single undo-entry that does a replacement
@@ -1279,7 +1281,8 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte,
1279 1281
1280void 1282void
1281replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, 1283replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1282 bool prepare, bool inherit, bool markers) 1284 bool prepare, bool inherit, bool markers,
1285 bool adjust_match_data)
1283{ 1286{
1284 ptrdiff_t inschars = SCHARS (new); 1287 ptrdiff_t inschars = SCHARS (new);
1285 ptrdiff_t insbytes = SBYTES (new); 1288 ptrdiff_t insbytes = SBYTES (new);
@@ -1426,6 +1429,9 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1426 MODIFF++; 1429 MODIFF++;
1427 CHARS_MODIFF = MODIFF; 1430 CHARS_MODIFF = MODIFF;
1428 1431
1432 if (adjust_match_data)
1433 update_search_regs (from, to, from + SCHARS (new));
1434
1429 signal_after_change (from, nchars_del, GPT - from); 1435 signal_after_change (from, nchars_del, GPT - from);
1430 update_compositions (from, GPT, CHECK_BORDER); 1436 update_compositions (from, GPT, CHECK_BORDER);
1431} 1437}