diff options
| author | Karl Heuer | 1995-06-09 01:10:11 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-06-09 01:10:11 +0000 |
| commit | 1e79ec2421054e89ec4451e82377f532f8a5be82 (patch) | |
| tree | 7a1d663e3c4dee49eb4ecb34d767b97d3258e37b /src | |
| parent | ad10348f71b094d88e6331b737208e46e8d37855 (diff) | |
| download | emacs-1e79ec2421054e89ec4451e82377f532f8a5be82.tar.gz emacs-1e79ec2421054e89ec4451e82377f532f8a5be82.zip | |
(Freplace_match): Do the right thing with backslash.
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/search.c b/src/search.c index 4fdbf8c7f0d..5b3192cebe1 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -1651,6 +1651,7 @@ which is made by replacing the part of STRING that was matched.") | |||
| 1651 | { | 1651 | { |
| 1652 | int substart = -1; | 1652 | int substart = -1; |
| 1653 | int subend; | 1653 | int subend; |
| 1654 | int delbackslash = 0; | ||
| 1654 | 1655 | ||
| 1655 | c = XSTRING (newtext)->data[pos]; | 1656 | c = XSTRING (newtext)->data[pos]; |
| 1656 | if (c == '\\') | 1657 | if (c == '\\') |
| @@ -1669,11 +1670,15 @@ which is made by replacing the part of STRING that was matched.") | |||
| 1669 | subend = search_regs.end[c - '0']; | 1670 | subend = search_regs.end[c - '0']; |
| 1670 | } | 1671 | } |
| 1671 | } | 1672 | } |
| 1673 | else if (c == '\\') | ||
| 1674 | delbackslash = 1; | ||
| 1672 | } | 1675 | } |
| 1673 | if (substart >= 0) | 1676 | if (substart >= 0) |
| 1674 | { | 1677 | { |
| 1675 | if (pos - 1 != lastpos + 1) | 1678 | if (pos - 1 != lastpos + 1) |
| 1676 | middle = Fsubstring (newtext, lastpos + 1, pos - 1); | 1679 | middle = Fsubstring (newtext, |
| 1680 | make_number (lastpos + 1), | ||
| 1681 | make_number (pos - 1)); | ||
| 1677 | else | 1682 | else |
| 1678 | middle = Qnil; | 1683 | middle = Qnil; |
| 1679 | accum = concat3 (accum, middle, | 1684 | accum = concat3 (accum, middle, |
| @@ -1681,10 +1686,18 @@ which is made by replacing the part of STRING that was matched.") | |||
| 1681 | make_number (subend))); | 1686 | make_number (subend))); |
| 1682 | lastpos = pos; | 1687 | lastpos = pos; |
| 1683 | } | 1688 | } |
| 1689 | else if (delbackslash) | ||
| 1690 | { | ||
| 1691 | middle = Fsubstring (newtext, make_number (lastpos + 1), | ||
| 1692 | make_number (pos)); | ||
| 1693 | accum = concat2 (accum, middle); | ||
| 1694 | lastpos = pos; | ||
| 1695 | } | ||
| 1684 | } | 1696 | } |
| 1685 | 1697 | ||
| 1686 | if (pos != lastpos + 1) | 1698 | if (pos != lastpos + 1) |
| 1687 | middle = Fsubstring (newtext, lastpos + 1, pos); | 1699 | middle = Fsubstring (newtext, make_number (lastpos + 1), |
| 1700 | make_number (pos)); | ||
| 1688 | else | 1701 | else |
| 1689 | middle = Qnil; | 1702 | middle = Qnil; |
| 1690 | 1703 | ||