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

Diff of /emacs/src/insdel.c

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

revision 1.166.4.4 by miles, Tue Jul 6 09:23:54 2004 UTC revision 1.166.4.5 by miles, Thu Nov 4 13:12:22 2004 UTC
# Line 1464  adjust_after_insert (from, from_byte, to Line 1464  adjust_after_insert (from, from_byte, to
1464    Z -= len; Z_BYTE -= len_byte;    Z -= len; Z_BYTE -= len_byte;
1465    adjust_after_replace (from, from_byte, Qnil, newlen, len_byte);    adjust_after_replace (from, from_byte, Qnil, newlen, len_byte);
1466  }  }
1467    
1468  /* Replace the text from character positions FROM to TO with NEW,  /* Replace the text from character positions FROM to TO with NEW,
1469     If PREPARE is nonzero, call prepare_to_modify_buffer.     If PREPARE is nonzero, call prepare_to_modify_buffer.
1470     If INHERIT, the newly inserted text should inherit text properties     If INHERIT, the newly inserted text should inherit text properties
# Line 1641  replace_range (from, to, new, prepare, i Line 1641  replace_range (from, to, new, prepare, i
1641    update_compositions (from, GPT, CHECK_BORDER);    update_compositions (from, GPT, CHECK_BORDER);
1642  }  }
1643    
1644    /* Replace the text from character positions FROM to TO with
1645       the text in INS of length INSCHARS.
1646       Keep the text properties that applied to the old characters
1647       (extending them to all the new chars if there are more new chars).
1648    
1649       Note that this does not yet handle markers quite right.
1650    
1651       If MARKERS is nonzero, relocate markers.
1652    
1653       Unlike most functions at this level, never call
1654       prepare_to_modify_buffer and never call signal_after_change.  */
1655    
1656    void
1657    replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
1658         int from, from_byte, to, to_byte;
1659         char *ins;
1660         int inschars, insbytes, markers;
1661    {
1662      int nbytes_del, nchars_del;
1663      Lisp_Object temp;
1664    
1665      CHECK_MARKERS ();
1666    
1667      nchars_del = to - from;
1668      nbytes_del = to_byte - from_byte;
1669    
1670      if (nbytes_del <= 0 && insbytes == 0)
1671        return;
1672    
1673      /* Make sure point-max won't overflow after this insertion.  */
1674      XSETINT (temp, Z_BYTE - nbytes_del + insbytes);
1675      if (Z_BYTE - nbytes_del + insbytes != XINT (temp))
1676        error ("Maximum buffer size exceeded");
1677    
1678      /* Make sure the gap is somewhere in or next to what we are deleting.  */
1679      if (from > GPT)
1680        gap_right (from, from_byte);
1681      if (to < GPT)
1682        gap_left (to, to_byte, 0);
1683    
1684      GAP_SIZE += nbytes_del;
1685      ZV -= nchars_del;
1686      Z -= nchars_del;
1687      ZV_BYTE -= nbytes_del;
1688      Z_BYTE -= nbytes_del;
1689      GPT = from;
1690      GPT_BYTE = from_byte;
1691      if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
1692    
1693      if (GPT_BYTE < GPT)
1694        abort ();
1695    
1696      if (GPT - BEG < BEG_UNCHANGED)
1697        BEG_UNCHANGED = GPT - BEG;
1698      if (Z - GPT < END_UNCHANGED)
1699        END_UNCHANGED = Z - GPT;
1700    
1701      if (GAP_SIZE < insbytes)
1702        make_gap (insbytes - GAP_SIZE);
1703    
1704      /* Copy the replacement text into the buffer.  */
1705      bcopy (ins, GPT_ADDR, insbytes);
1706    
1707    #ifdef BYTE_COMBINING_DEBUG
1708      /* We have copied text into the gap, but we have not marked
1709         it as part of the buffer.  So we can use the old FROM and FROM_BYTE
1710         here, for both the previous text and the following text.
1711         Meanwhile, GPT_ADDR does point to
1712         the text that has been stored by copy_text.  */
1713      if (count_combining_before (GPT_ADDR, insbytes, from, from_byte)
1714          || count_combining_after (GPT_ADDR, insbytes, from, from_byte))
1715        abort ();
1716    #endif
1717    
1718      GAP_SIZE -= insbytes;
1719      GPT += inschars;
1720      ZV += inschars;
1721      Z += inschars;
1722      GPT_BYTE += insbytes;
1723      ZV_BYTE += insbytes;
1724      Z_BYTE += insbytes;
1725      if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
1726    
1727      if (GPT_BYTE < GPT)
1728        abort ();
1729    
1730      /* Adjust the overlay center as needed.  This must be done after
1731         adjusting the markers that bound the overlays.  */
1732      if (nchars_del != inschars)
1733        {
1734          adjust_overlays_for_insert (from, inschars);
1735          adjust_overlays_for_delete (from + inschars, nchars_del);
1736        }
1737    
1738      /* Adjust markers for the deletion and the insertion.  */
1739      if (markers
1740          && ! (nchars_del == 1 && inschars == 1))
1741        adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1742                                    inschars, insbytes);
1743    
1744      offset_intervals (current_buffer, from, inschars - nchars_del);
1745    
1746      /* Relocate point as if it were a marker.  */
1747      if (from < PT && nchars_del != inschars)
1748        adjust_point ((from + inschars - (PT < to ? PT : to)),
1749                      (from_byte + insbytes
1750                       - (PT_BYTE < to_byte ? PT_BYTE : to_byte)));
1751    
1752      if (insbytes == 0)
1753        evaporate_overlays (from);
1754    
1755      CHECK_MARKERS ();
1756    
1757      MODIFF++;
1758    }
1759    
1760  /* Delete characters in current buffer  /* Delete characters in current buffer
1761     from FROM up to (but not including) TO.     from FROM up to (but not including) TO.
1762     If TO comes before FROM, we delete nothing.  */     If TO comes before FROM, we delete nothing.  */

Legend:
Removed from v.1.166.4.4  
changed lines
  Added in v.1.166.4.5

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