Mercurial > emacs
changeset 2655:594a33ffed85
* search.c (Freplace_match): Arrange for markers sitting at the
beginning or end of the original text to float to the
corresponding position in the replacement text.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 04 May 1993 02:35:38 +0000 |
parents | ba685dcc3750 |
children | 93eda11d38de |
files | src/search.c |
diffstat | 1 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/search.c Tue May 04 02:35:01 1993 +0000 +++ b/src/search.c Tue May 04 02:35:38 1993 +0000 @@ -1236,7 +1236,11 @@ case_action = nochange; } - SET_PT (search_regs.end[0]); + /* We insert the replacement text before the old text, and then + 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. */ + SET_PT (search_regs.start[0]); if (!NILP (literal)) Finsert (1, &string); else @@ -1246,20 +1250,24 @@ for (pos = 0; pos < XSTRING (string)->size; pos++) { + int offset = point - search_regs.start[0]; + c = XSTRING (string)->data[pos]; if (c == '\\') { c = XSTRING (string)->data[++pos]; if (c == '&') - Finsert_buffer_substring (Fcurrent_buffer (), - make_number (search_regs.start[0]), - make_number (search_regs.end[0])); + Finsert_buffer_substring + (Fcurrent_buffer (), + make_number (search_regs.start[0] + offset), + make_number (search_regs.end[0] + offset)); else if (c >= '1' && c <= search_regs.num_regs + '0') { if (search_regs.start[c - '0'] >= 1) - Finsert_buffer_substring (Fcurrent_buffer (), - make_number (search_regs.start[c - '0']), - make_number (search_regs.end[c - '0'])); + Finsert_buffer_substring + (Fcurrent_buffer (), + make_number (search_regs.start[c - '0'] + offset), + make_number (search_regs.end[c - '0'] + offset)); } else insert_char (c); @@ -1270,8 +1278,8 @@ UNGCPRO; } - inslen = point - (search_regs.end[0]); - del_range (search_regs.start[0], search_regs.end[0]); + inslen = point - (search_regs.start[0]); + del_range (search_regs.start[0] + inslen, search_regs.end[0] + inslen); if (case_action == all_caps) Fupcase_region (make_number (point - inslen), make_number (point));