diff options
| author | Richard M. Stallman | 2001-11-11 20:04:04 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-11-11 20:04:04 +0000 |
| commit | 886ed6ec125599d2dd4d55151300fa5c9ff004a8 (patch) | |
| tree | 46611cf2c7512aaedfe3f1ca7dfeb8ff3dcea050 /src | |
| parent | 78ff4175b92b108b2476affb87edd3f074e03580 (diff) | |
| download | emacs-886ed6ec125599d2dd4d55151300fa5c9ff004a8.tar.gz emacs-886ed6ec125599d2dd4d55151300fa5c9ff004a8.zip | |
(Freplace_match): Use replace_range to insert and delete.
Don't request property inheritance from surrounding text.
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/search.c b/src/search.c index a7e27c88ecd..7491debcdea 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2424,15 +2424,9 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2424 | else | 2424 | else |
| 2425 | opoint = PT; | 2425 | opoint = PT; |
| 2426 | 2426 | ||
| 2427 | TEMP_SET_PT (search_regs.start[sub]); | 2427 | /* If we want non-literal replacement, |
| 2428 | 2428 | perform substitution on the replacement string. */ | |
| 2429 | /* We insert the replacement text before the old text, and then | 2429 | if (NILP (literal)) |
| 2430 | delete the original text. This means that markers at the | ||
| 2431 | beginning or end of the original will float to the corresponding | ||
| 2432 | position in the replacement. */ | ||
| 2433 | if (!NILP (literal)) | ||
| 2434 | Finsert_and_inherit (1, &newtext); | ||
| 2435 | else | ||
| 2436 | { | 2430 | { |
| 2437 | int length = STRING_BYTES (XSTRING (newtext)); | 2431 | int length = STRING_BYTES (XSTRING (newtext)); |
| 2438 | unsigned char *substed; | 2432 | unsigned char *substed; |
| @@ -2440,6 +2434,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2440 | int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); | 2434 | int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 2441 | int str_multibyte = STRING_MULTIBYTE (newtext); | 2435 | int str_multibyte = STRING_MULTIBYTE (newtext); |
| 2442 | Lisp_Object rev_tbl; | 2436 | Lisp_Object rev_tbl; |
| 2437 | int really_changed = 0; | ||
| 2443 | 2438 | ||
| 2444 | rev_tbl= (!buf_multibyte && CHAR_TABLE_P (Vnonascii_translation_table) | 2439 | rev_tbl= (!buf_multibyte && CHAR_TABLE_P (Vnonascii_translation_table) |
| 2445 | ? Fchar_table_extra_slot (Vnonascii_translation_table, | 2440 | ? Fchar_table_extra_slot (Vnonascii_translation_table, |
| @@ -2481,6 +2476,8 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2481 | 2476 | ||
| 2482 | if (c == '\\') | 2477 | if (c == '\\') |
| 2483 | { | 2478 | { |
| 2479 | really_changed = 1; | ||
| 2480 | |||
| 2484 | if (str_multibyte) | 2481 | if (str_multibyte) |
| 2485 | { | 2482 | { |
| 2486 | FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, newtext, | 2483 | FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, newtext, |
| @@ -2546,21 +2543,23 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2546 | } | 2543 | } |
| 2547 | } | 2544 | } |
| 2548 | 2545 | ||
| 2549 | /* Now insert what we accumulated. */ | 2546 | if (really_changed) |
| 2550 | insert_and_inherit (substed, substed_len); | 2547 | newtext = make_string (substed, substed_len); |
| 2551 | 2548 | ||
| 2552 | xfree (substed); | 2549 | xfree (substed); |
| 2553 | } | 2550 | } |
| 2554 | 2551 | ||
| 2555 | inslen = PT - (search_regs.start[sub]); | 2552 | /* Replace the old text with the new in the cleanest possible way. */ |
| 2556 | del_range (search_regs.start[sub] + inslen, search_regs.end[sub] + inslen); | 2553 | replace_range (search_regs.start[sub], search_regs.end[sub], |
| 2554 | newtext, 1, 0, 1); | ||
| 2555 | newpoint = search_regs.start[sub] + XSTRING (newtext)->size; | ||
| 2557 | 2556 | ||
| 2558 | if (case_action == all_caps) | 2557 | if (case_action == all_caps) |
| 2559 | Fupcase_region (make_number (PT - inslen), make_number (PT)); | 2558 | Fupcase_region (make_number (search_regs.start[sub]), |
| 2559 | make_number (newpoint)); | ||
| 2560 | else if (case_action == cap_initial) | 2560 | else if (case_action == cap_initial) |
| 2561 | Fupcase_initials_region (make_number (PT - inslen), make_number (PT)); | 2561 | Fupcase_initials_region (make_number (search_regs.start[sub]), |
| 2562 | 2562 | make_number (newpoint)); | |
| 2563 | newpoint = PT; | ||
| 2564 | 2563 | ||
| 2565 | /* Put point back where it was in the text. */ | 2564 | /* Put point back where it was in the text. */ |
| 2566 | if (opoint <= 0) | 2565 | if (opoint <= 0) |