/[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.175.2.4 by miles, Mon Jun 28 07:29:21 2004 UTC revision 1.175.2.5 by miles, Thu Nov 4 08:55:31 2004 UTC
# Line 1497  adjust_after_insert (from, from_byte, to Line 1497  adjust_after_insert (from, from_byte, to
1497    Z -= len; Z_BYTE -= len_byte;    Z -= len; Z_BYTE -= len_byte;
1498    adjust_after_replace (from, from_byte, Qnil, newlen, len_byte);    adjust_after_replace (from, from_byte, Qnil, newlen, len_byte);
1499  }  }
1500    
1501  /* Replace the text from character positions FROM to TO with NEW,  /* Replace the text from character positions FROM to TO with NEW,
1502     If PREPARE is nonzero, call prepare_to_modify_buffer.     If PREPARE is nonzero, call prepare_to_modify_buffer.
1503     If INHERIT, the newly inserted text should inherit text properties     If INHERIT, the newly inserted text should inherit text properties
# Line 1674  replace_range (from, to, new, prepare, i Line 1674  replace_range (from, to, new, prepare, i
1674    update_compositions (from, GPT, CHECK_BORDER);    update_compositions (from, GPT, CHECK_BORDER);
1675  }  }
1676    
1677    /* Replace the text from character positions FROM to TO with
1678       the text in INS of length INSCHARS.
1679       Keep the text properties that applied to the old characters
1680       (extending them to all the new chars if there are more new chars).
1681    
1682       Note that this does not yet handle markers quite right.
1683    
1684       If MARKERS is nonzero, relocate markers.
1685    
1686       Unlike most functions at this level, never call
1687       prepare_to_modify_buffer and never call signal_after_change.  */
1688    
1689    void
1690    replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
1691         int from, from_byte, to, to_byte;
1692         char *ins;
1693         int inschars, insbytes, markers;
1694    {
1695      int nbytes_del, nchars_del;
1696      Lisp_Object temp;
1697    
1698      CHECK_MARKERS ();
1699    
1700      nchars_del = to - from;
1701      nbytes_del = to_byte - from_byte;
1702    
1703      if (nbytes_del <= 0 && insbytes == 0)
1704        return;
1705    
1706      /* Make sure point-max won't overflow after this insertion.  */
1707      XSETINT (temp, Z_BYTE - nbytes_del + insbytes);
1708      if (Z_BYTE - nbytes_del + insbytes != XINT (temp))
1709        error ("Maximum buffer size exceeded");
1710    
1711      /* Make sure the gap is somewhere in or next to what we are deleting.  */
1712      if (from > GPT)
1713        gap_right (from, from_byte);
1714      if (to < GPT)
1715        gap_left (to, to_byte, 0);
1716    
1717      GAP_SIZE += nbytes_del;
1718      ZV -= nchars_del;
1719      Z -= nchars_del;
1720      ZV_BYTE -= nbytes_del;
1721      Z_BYTE -= nbytes_del;
1722      GPT = from;
1723      GPT_BYTE = from_byte;
1724      if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
1725    
1726      if (GPT_BYTE < GPT)
1727        abort ();
1728    
1729      if (GPT - BEG < BEG_UNCHANGED)
1730        BEG_UNCHANGED = GPT - BEG;
1731      if (Z - GPT < END_UNCHANGED)
1732        END_UNCHANGED = Z - GPT;
1733    
1734      if (GAP_SIZE < insbytes)
1735        make_gap (insbytes - GAP_SIZE);
1736    
1737      /* Copy the replacement text into the buffer.  */
1738      bcopy (ins, GPT_ADDR, insbytes);
1739    
1740    #ifdef BYTE_COMBINING_DEBUG
1741      /* We have copied text into the gap, but we have not marked
1742         it as part of the buffer.  So we can use the old FROM and FROM_BYTE
1743         here, for both the previous text and the following text.
1744         Meanwhile, GPT_ADDR does point to
1745         the text that has been stored by copy_text.  */
1746      if (count_combining_before (GPT_ADDR, insbytes, from, from_byte)
1747          || count_combining_after (GPT_ADDR, insbytes, from, from_byte))
1748        abort ();
1749    #endif
1750    
1751      GAP_SIZE -= insbytes;
1752      GPT += inschars;
1753      ZV += inschars;
1754      Z += inschars;
1755      GPT_BYTE += insbytes;
1756      ZV_BYTE += insbytes;
1757      Z_BYTE += insbytes;
1758      if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
1759    
1760      if (GPT_BYTE < GPT)
1761        abort ();
1762    
1763      /* Adjust the overlay center as needed.  This must be done after
1764         adjusting the markers that bound the overlays.  */
1765      if (nchars_del != inschars)
1766        {
1767          adjust_overlays_for_insert (from, inschars);
1768          adjust_overlays_for_delete (from + inschars, nchars_del);
1769        }
1770    
1771      /* Adjust markers for the deletion and the insertion.  */
1772      if (markers
1773          && ! (nchars_del == 1 && inschars == 1))
1774        adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
1775                                    inschars, insbytes);
1776    
1777      offset_intervals (current_buffer, from, inschars - nchars_del);
1778    
1779      /* Relocate point as if it were a marker.  */
1780      if (from < PT && nchars_del != inschars)
1781        adjust_point ((from + inschars - (PT < to ? PT : to)),
1782                      (from_byte + insbytes
1783                       - (PT_BYTE < to_byte ? PT_BYTE : to_byte)));
1784    
1785      if (insbytes == 0)
1786        evaporate_overlays (from);
1787    
1788      CHECK_MARKERS ();
1789    
1790      MODIFF++;
1791    }
1792    
1793  /* Delete characters in current buffer  /* Delete characters in current buffer
1794     from FROM up to (but not including) TO.     from FROM up to (but not including) TO.
1795     If TO comes before FROM, we delete nothing.  */     If TO comes before FROM, we delete nothing.  */

Legend:
Removed from v.1.175.2.4  
changed lines
  Added in v.1.175.2.5

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