aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-05-31 07:40:46 +0000
committerRichard M. Stallman1997-05-31 07:40:46 +0000
commitb0eba9913232b3da6075541591698ce27f48bde9 (patch)
tree444cc49ae0b5d104c99b1fe80fa249b433c9aa43 /src
parenta7fa233fe7cdaf7ae15973ecc3c93286af093ea4 (diff)
downloademacs-b0eba9913232b3da6075541591698ce27f48bde9.tar.gz
emacs-b0eba9913232b3da6075541591698ce27f48bde9.zip
(Freplace_match): Use move_if_not_intangible
to handle intangible text better. (looking_at_1): Change using DOWNCASE_TABLE. (string_match_1): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/search.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/search.c b/src/search.c
index fde9a8a1d0d..720012dfc5a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -225,7 +225,7 @@ looking_at_1 (string, posix)
225 CHECK_STRING (string, 0); 225 CHECK_STRING (string, 0);
226 bufp = compile_pattern (string, &search_regs, 226 bufp = compile_pattern (string, &search_regs,
227 (!NILP (current_buffer->case_fold_search) 227 (!NILP (current_buffer->case_fold_search)
228 ? DOWNCASE_TABLE : 0), 228 ? XCHAR_TABLE (DOWNCASE_TABLE)->contents : 0),
229 posix); 229 posix);
230 230
231 immediate_quit = 1; 231 immediate_quit = 1;
@@ -324,7 +324,7 @@ string_match_1 (regexp, string, start, posix)
324 324
325 bufp = compile_pattern (regexp, &search_regs, 325 bufp = compile_pattern (regexp, &search_regs,
326 (!NILP (current_buffer->case_fold_search) 326 (!NILP (current_buffer->case_fold_search)
327 ? DOWNCASE_TABLE : 0), 327 ? XCHAR_TABLE (DOWNCASE_TABLE)->contents : 0),
328 posix); 328 posix);
329 immediate_quit = 1; 329 immediate_quit = 1;
330 re_match_object = string; 330 re_match_object = string;
@@ -1422,6 +1422,7 @@ since only regular expressions have distinguished subexpressions.")
1422 register int c, prevc; 1422 register int c, prevc;
1423 int inslen; 1423 int inslen;
1424 int sub; 1424 int sub;
1425 int opoint;
1425 1426
1426 CHECK_STRING (newtext, 0); 1427 CHECK_STRING (newtext, 0);
1427 1428
@@ -1615,11 +1616,18 @@ since only regular expressions have distinguished subexpressions.")
1615 return concat3 (before, newtext, after); 1616 return concat3 (before, newtext, after);
1616 } 1617 }
1617 1618
1619 /* Record point, the move (quietly) to the start of the match. */
1620 if (PT > search_regs.start[sub])
1621 opoint = PT - ZV;
1622 else
1623 opoint = PT;
1624
1625 temp_set_point (search_regs.start[sub], current_buffer);
1626
1618 /* We insert the replacement text before the old text, and then 1627 /* We insert the replacement text before the old text, and then
1619 delete the original text. This means that markers at the 1628 delete the original text. This means that markers at the
1620 beginning or end of the original will float to the corresponding 1629 beginning or end of the original will float to the corresponding
1621 position in the replacement. */ 1630 position in the replacement. */
1622 SET_PT (search_regs.start[sub]);
1623 if (!NILP (literal)) 1631 if (!NILP (literal))
1624 Finsert_and_inherit (1, &newtext); 1632 Finsert_and_inherit (1, &newtext);
1625 else 1633 else
@@ -1666,6 +1674,16 @@ since only regular expressions have distinguished subexpressions.")
1666 Fupcase_region (make_number (PT - inslen), make_number (PT)); 1674 Fupcase_region (make_number (PT - inslen), make_number (PT));
1667 else if (case_action == cap_initial) 1675 else if (case_action == cap_initial)
1668 Fupcase_initials_region (make_number (PT - inslen), make_number (PT)); 1676 Fupcase_initials_region (make_number (PT - inslen), make_number (PT));
1677
1678 /* Put point back where it was in the text. */
1679 if (opoint < 0)
1680 temp_set_point (opoint + ZV, current_buffer);
1681 else
1682 temp_set_point (opoint, current_buffer);
1683
1684 /* Now move point "officially" to the start of the inserted replacement. */
1685 move_if_not_intangible (search_regs.start[sub]);
1686
1669 return Qnil; 1687 return Qnil;
1670} 1688}
1671 1689