2424 |
else |
else |
2425 |
opoint = PT; |
opoint = PT; |
2426 |
|
|
2427 |
TEMP_SET_PT (search_regs.start[sub]); |
/* If we want non-literal replacement, |
2428 |
|
perform substitution on the replacement string. */ |
2429 |
/* We insert the replacement text before the old text, and then |
if (NILP (literal)) |
|
delete the original text. This means that markers at the |
|
|
beginning or end of the original will float to the corresponding |
|
|
position in the replacement. */ |
|
|
if (!NILP (literal)) |
|
|
Finsert_and_inherit (1, &newtext); |
|
|
else |
|
2430 |
{ |
{ |
2431 |
int length = STRING_BYTES (XSTRING (newtext)); |
int length = STRING_BYTES (XSTRING (newtext)); |
2432 |
unsigned char *substed; |
unsigned char *substed; |
2434 |
int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); |
int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters); |
2435 |
int str_multibyte = STRING_MULTIBYTE (newtext); |
int str_multibyte = STRING_MULTIBYTE (newtext); |
2436 |
Lisp_Object rev_tbl; |
Lisp_Object rev_tbl; |
2437 |
|
int really_changed = 0; |
2438 |
|
|
2439 |
rev_tbl= (!buf_multibyte && CHAR_TABLE_P (Vnonascii_translation_table) |
rev_tbl= (!buf_multibyte && CHAR_TABLE_P (Vnonascii_translation_table) |
2440 |
? Fchar_table_extra_slot (Vnonascii_translation_table, |
? Fchar_table_extra_slot (Vnonascii_translation_table, |
2476 |
|
|
2477 |
if (c == '\\') |
if (c == '\\') |
2478 |
{ |
{ |
2479 |
|
really_changed = 1; |
2480 |
|
|
2481 |
if (str_multibyte) |
if (str_multibyte) |
2482 |
{ |
{ |
2483 |
FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, newtext, |
FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, newtext, |
2543 |
} |
} |
2544 |
} |
} |
2545 |
|
|
2546 |
/* Now insert what we accumulated. */ |
if (really_changed) |
2547 |
insert_and_inherit (substed, substed_len); |
newtext = make_string (substed, substed_len); |
2548 |
|
|
2549 |
xfree (substed); |
xfree (substed); |
2550 |
} |
} |
2551 |
|
|
2552 |
inslen = PT - (search_regs.start[sub]); |
/* Replace the old text with the new in the cleanest possible way. */ |
2553 |
del_range (search_regs.start[sub] + inslen, search_regs.end[sub] + inslen); |
replace_range (search_regs.start[sub], search_regs.end[sub], |
2554 |
|
newtext, 1, 0, 1); |
2555 |
|
newpoint = search_regs.start[sub] + XSTRING (newtext)->size; |
2556 |
|
|
2557 |
if (case_action == all_caps) |
if (case_action == all_caps) |
2558 |
Fupcase_region (make_number (PT - inslen), make_number (PT)); |
Fupcase_region (make_number (search_regs.start[sub]), |
2559 |
|
make_number (newpoint)); |
2560 |
else if (case_action == cap_initial) |
else if (case_action == cap_initial) |
2561 |
Fupcase_initials_region (make_number (PT - inslen), make_number (PT)); |
Fupcase_initials_region (make_number (search_regs.start[sub]), |
2562 |
|
make_number (newpoint)); |
|
newpoint = PT; |
|
2563 |
|
|
2564 |
/* Put point back where it was in the text. */ |
/* Put point back where it was in the text. */ |
2565 |
if (opoint <= 0) |
if (opoint <= 0) |