diff options
| author | Noam Postavsky | 2016-07-20 20:15:14 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2016-07-22 23:55:23 -0400 |
| commit | 66f95e0dabf750e9d2eff59b2bb6e593618cd48a (patch) | |
| tree | a8cd27828bfef2459b70e446cdf1de346327fc3e /src/editfns.c | |
| parent | 52cf0d5d98c51c3591ca5d376fd4e85cd9b72d7f (diff) | |
| download | emacs-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/editfns.c')
| -rw-r--r-- | src/editfns.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/editfns.c b/src/editfns.c index 412745d551d..32c8bec6db2 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3192,7 +3192,7 @@ Both characters must have the same length of multi-byte form. */) | |||
| 3192 | /* replace_range is less efficient, because it moves the gap, | 3192 | /* replace_range is less efficient, because it moves the gap, |
| 3193 | but it handles combining correctly. */ | 3193 | but it handles combining correctly. */ |
| 3194 | replace_range (pos, pos + 1, string, | 3194 | replace_range (pos, pos + 1, string, |
| 3195 | 0, 0, 1); | 3195 | 0, 0, 1, 0); |
| 3196 | pos_byte_next = CHAR_TO_BYTE (pos); | 3196 | pos_byte_next = CHAR_TO_BYTE (pos); |
| 3197 | if (pos_byte_next > pos_byte) | 3197 | if (pos_byte_next > pos_byte) |
| 3198 | /* Before combining happened. We should not increment | 3198 | /* Before combining happened. We should not increment |
| @@ -3405,7 +3405,7 @@ It returns the number of characters changed. */) | |||
| 3405 | /* This is less efficient, because it moves the gap, | 3405 | /* This is less efficient, because it moves the gap, |
| 3406 | but it should handle multibyte characters correctly. */ | 3406 | but it should handle multibyte characters correctly. */ |
| 3407 | string = make_multibyte_string ((char *) str, 1, str_len); | 3407 | string = make_multibyte_string ((char *) str, 1, str_len); |
| 3408 | replace_range (pos, pos + 1, string, 1, 0, 1); | 3408 | replace_range (pos, pos + 1, string, 1, 0, 1, 0); |
| 3409 | len = str_len; | 3409 | len = str_len; |
| 3410 | } | 3410 | } |
| 3411 | else | 3411 | else |
| @@ -3446,7 +3446,7 @@ It returns the number of characters changed. */) | |||
| 3446 | { | 3446 | { |
| 3447 | string = Fmake_string (make_number (1), val); | 3447 | string = Fmake_string (make_number (1), val); |
| 3448 | } | 3448 | } |
| 3449 | replace_range (pos, pos + len, string, 1, 0, 1); | 3449 | replace_range (pos, pos + len, string, 1, 0, 1, 0); |
| 3450 | pos_byte += SBYTES (string); | 3450 | pos_byte += SBYTES (string); |
| 3451 | pos += SCHARS (string); | 3451 | pos += SCHARS (string); |
| 3452 | cnt += SCHARS (string); | 3452 | cnt += SCHARS (string); |