diff options
author | Noam Postavsky <npostavs@gmail.com> | 2016-07-20 20:15:14 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2016-07-22 23:55:23 -0400 |
commit | 66f95e0dabf750e9d2eff59b2bb6e593618cd48a (patch) | |
tree | a8cd27828bfef2459b70e446cdf1de346327fc3e /src/insdel.c | |
parent | 52cf0d5d98c51c3591ca5d376fd4e85cd9b72d7f (diff) | |
download | emacs-66f95e0dabf750e9d2eff59b2bb6e593618cd48a.tar.gz |
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.c | 10 |
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, /* Replace the text from character positions FROM to TO with NEW, If PREPARE, call prepare_to_modify_buffer. If INHERIT, the newly inserted text should inherit text properties - from the surrounding non-deleted text. */ + from the surrounding non-deleted text. + If ADJUST_MATCH_DATA, then adjust the match data before calling + signal_after_change. */ /* Note that this does not yet handle markers quite right. 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, void replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, - bool prepare, bool inherit, bool markers) + bool prepare, bool inherit, bool markers, + bool adjust_match_data) { ptrdiff_t inschars = SCHARS (new); ptrdiff_t insbytes = SBYTES (new); @@ -1426,6 +1429,9 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, MODIFF++; CHARS_MODIFF = MODIFF; + if (adjust_match_data) + update_search_regs (from, to, from + SCHARS (new)); + signal_after_change (from, nchars_del, GPT - from); update_compositions (from, GPT, CHECK_BORDER); } |