Mercurial > emacs
comparison src/search.c @ 18077:27a0ced43e7e
(Freplace_match): Use move_if_not_intangible
to handle intangible text better.
(looking_at_1): Change using DOWNCASE_TABLE.
(string_match_1): Likewise.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 31 May 1997 07:40:46 +0000 |
parents | bb9ae80d22e2 |
children | 300068b4fcef |
comparison
equal
deleted
inserted
replaced
18076:1a2e6b512688 | 18077:27a0ced43e7e |
---|---|
223 save_search_regs (); | 223 save_search_regs (); |
224 | 224 |
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; |
232 QUIT; /* Do a pending quit right away, to avoid paradoxical behavior */ | 232 QUIT; /* Do a pending quit right away, to avoid paradoxical behavior */ |
233 | 233 |
322 args_out_of_range (string, start); | 322 args_out_of_range (string, start); |
323 } | 323 } |
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; |
331 | 331 |
332 val = re_search (bufp, (char *) XSTRING (string)->data, | 332 val = re_search (bufp, (char *) XSTRING (string)->data, |
1420 int some_uppercase; | 1420 int some_uppercase; |
1421 int some_nonuppercase_initial; | 1421 int some_nonuppercase_initial; |
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 |
1428 if (! NILP (string)) | 1429 if (! NILP (string)) |
1429 CHECK_STRING (string, 4); | 1430 CHECK_STRING (string, 4); |
1613 newtext = Fupcase_initials (newtext); | 1614 newtext = Fupcase_initials (newtext); |
1614 | 1615 |
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 |
1626 { | 1634 { |
1627 struct gcpro gcpro1; | 1635 struct gcpro gcpro1; |
1664 | 1672 |
1665 if (case_action == all_caps) | 1673 if (case_action == all_caps) |
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 |
1672 static Lisp_Object | 1690 static Lisp_Object |
1673 match_limit (num, beginningp) | 1691 match_limit (num, beginningp) |