/[emacs]/emacs/src/search.c
ViewVC logotype

Diff of /emacs/src/search.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.160 by pj, Fri Nov 2 20:33:08 2001 UTC revision 1.161 by rms, Sun Nov 11 20:04:04 2001 UTC
# Line 2424  since only regular expressions have dist Line 2424  since only regular expressions have dist
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;
# Line 2440  since only regular expressions have dist Line 2434  since only regular expressions have dist
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,
# Line 2481  since only regular expressions have dist Line 2476  since only regular expressions have dist
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,
# Line 2546  since only regular expressions have dist Line 2543  since only regular expressions have dist
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)

Legend:
Removed from v.1.160  
changed lines
  Added in v.1.161

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26