diff options
| author | Richard M. Stallman | 1998-05-16 20:34:59 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-16 20:34:59 +0000 |
| commit | 0aa8c4b24d1941b60ae6e89c406fb1cd9b5bc5ce (patch) | |
| tree | 2671d592c53a7344c6579e24190dd8cfd86a99fd | |
| parent | f5321b5c8a5fe2e79344f79f790283ae3a13c2a8 (diff) | |
| download | emacs-0aa8c4b24d1941b60ae6e89c406fb1cd9b5bc5ce.tar.gz emacs-0aa8c4b24d1941b60ae6e89c406fb1cd9b5bc5ce.zip | |
(insert_1_both, insert_from_string_1, replace_range)
(insert_from_buffer_1, adjust_before_replace, adjust_after_replace):
Don't copy text being deleted, if undo is disabled.
| -rw-r--r-- | src/insdel.c | 175 |
1 files changed, 119 insertions, 56 deletions
diff --git a/src/insdel.c b/src/insdel.c index 9c01c333f0b..481f6bf267a 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -1014,7 +1014,7 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | |||
| 1014 | register int nchars, nbytes; | 1014 | register int nchars, nbytes; |
| 1015 | int inherit, prepare, before_markers; | 1015 | int inherit, prepare, before_markers; |
| 1016 | { | 1016 | { |
| 1017 | register Lisp_Object temp, deletion; | 1017 | register Lisp_Object temp; |
| 1018 | int combined_before_bytes, combined_after_bytes; | 1018 | int combined_before_bytes, combined_after_bytes; |
| 1019 | 1019 | ||
| 1020 | if (NILP (current_buffer->enable_multibyte_characters)) | 1020 | if (NILP (current_buffer->enable_multibyte_characters)) |
| @@ -1045,23 +1045,33 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | |||
| 1045 | 1045 | ||
| 1046 | if (combined_after_bytes) | 1046 | if (combined_after_bytes) |
| 1047 | { | 1047 | { |
| 1048 | deletion = make_buffer_string_both (PT, PT_BYTE, | 1048 | Lisp_Object deletion; |
| 1049 | PT + combined_after_bytes, | 1049 | deletion = Qnil; |
| 1050 | PT_BYTE + combined_after_bytes, 1); | 1050 | |
| 1051 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1052 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1053 | PT + combined_after_bytes, | ||
| 1054 | PT_BYTE + combined_after_bytes, 1); | ||
| 1051 | 1055 | ||
| 1052 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1056 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1053 | PT + combined_after_bytes, | 1057 | PT + combined_after_bytes, |
| 1054 | PT_BYTE + combined_after_bytes); | 1058 | PT_BYTE + combined_after_bytes); |
| 1055 | record_delete (PT, deletion); | 1059 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1060 | record_delete (PT, deletion); | ||
| 1056 | } | 1061 | } |
| 1057 | 1062 | ||
| 1058 | if (combined_before_bytes) | 1063 | if (combined_before_bytes) |
| 1059 | { | 1064 | { |
| 1060 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | 1065 | Lisp_Object deletion; |
| 1061 | PT, PT_BYTE, 1); | 1066 | deletion = Qnil; |
| 1067 | |||
| 1068 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1069 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1070 | PT, PT_BYTE, 1); | ||
| 1062 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1071 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1063 | PT, PT_BYTE); | 1072 | PT, PT_BYTE); |
| 1064 | record_delete (PT - 1, deletion); | 1073 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1074 | record_delete (PT - 1, deletion); | ||
| 1065 | } | 1075 | } |
| 1066 | 1076 | ||
| 1067 | record_insert (PT - !!combined_before_bytes, | 1077 | record_insert (PT - !!combined_before_bytes, |
| @@ -1170,7 +1180,6 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1170 | int combined_before_bytes, combined_after_bytes; | 1180 | int combined_before_bytes, combined_after_bytes; |
| 1171 | int adjusted_nchars; | 1181 | int adjusted_nchars; |
| 1172 | INTERVAL intervals; | 1182 | INTERVAL intervals; |
| 1173 | Lisp_Object deletion; | ||
| 1174 | 1183 | ||
| 1175 | /* Make OUTGOING_NBYTES describe the text | 1184 | /* Make OUTGOING_NBYTES describe the text |
| 1176 | as it will be inserted in this buffer. */ | 1185 | as it will be inserted in this buffer. */ |
| @@ -1220,23 +1229,33 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1220 | 1229 | ||
| 1221 | if (combined_after_bytes) | 1230 | if (combined_after_bytes) |
| 1222 | { | 1231 | { |
| 1223 | deletion = make_buffer_string_both (PT, PT_BYTE, | 1232 | Lisp_Object deletion; |
| 1224 | PT + combined_after_bytes, | 1233 | deletion = Qnil; |
| 1225 | PT_BYTE + combined_after_bytes, 1); | 1234 | |
| 1235 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1236 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1237 | PT + combined_after_bytes, | ||
| 1238 | PT_BYTE + combined_after_bytes, 1); | ||
| 1226 | 1239 | ||
| 1227 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1240 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1228 | PT + combined_after_bytes, | 1241 | PT + combined_after_bytes, |
| 1229 | PT_BYTE + combined_after_bytes); | 1242 | PT_BYTE + combined_after_bytes); |
| 1230 | record_delete (PT, deletion); | 1243 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1244 | record_delete (PT, deletion); | ||
| 1231 | } | 1245 | } |
| 1232 | 1246 | ||
| 1233 | if (combined_before_bytes) | 1247 | if (combined_before_bytes) |
| 1234 | { | 1248 | { |
| 1235 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | 1249 | Lisp_Object deletion; |
| 1236 | PT, PT_BYTE, 1); | 1250 | deletion = Qnil; |
| 1251 | |||
| 1252 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1253 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1254 | PT, PT_BYTE, 1); | ||
| 1237 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1255 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1238 | PT, PT_BYTE); | 1256 | PT, PT_BYTE); |
| 1239 | record_delete (PT - 1, deletion); | 1257 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1258 | record_delete (PT - 1, deletion); | ||
| 1240 | } | 1259 | } |
| 1241 | 1260 | ||
| 1242 | record_insert (PT - !!combined_before_bytes, | 1261 | record_insert (PT - !!combined_before_bytes, |
| @@ -1318,7 +1337,7 @@ insert_from_buffer_1 (buf, from, nchars, inherit) | |||
| 1318 | int from, nchars; | 1337 | int from, nchars; |
| 1319 | int inherit; | 1338 | int inherit; |
| 1320 | { | 1339 | { |
| 1321 | register Lisp_Object temp, deletion; | 1340 | register Lisp_Object temp; |
| 1322 | int chunk; | 1341 | int chunk; |
| 1323 | int from_byte = buf_charpos_to_bytepos (buf, from); | 1342 | int from_byte = buf_charpos_to_bytepos (buf, from); |
| 1324 | int to_byte = buf_charpos_to_bytepos (buf, from + nchars); | 1343 | int to_byte = buf_charpos_to_bytepos (buf, from + nchars); |
| @@ -1391,23 +1410,33 @@ insert_from_buffer_1 (buf, from, nchars, inherit) | |||
| 1391 | 1410 | ||
| 1392 | if (combined_after_bytes) | 1411 | if (combined_after_bytes) |
| 1393 | { | 1412 | { |
| 1394 | deletion = make_buffer_string_both (PT, PT_BYTE, | 1413 | Lisp_Object deletion; |
| 1395 | PT + combined_after_bytes, | 1414 | deletion = Qnil; |
| 1396 | PT_BYTE + combined_after_bytes, 1); | 1415 | |
| 1416 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1417 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1418 | PT + combined_after_bytes, | ||
| 1419 | PT_BYTE + combined_after_bytes, 1); | ||
| 1397 | 1420 | ||
| 1398 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1421 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1399 | PT + combined_after_bytes, | 1422 | PT + combined_after_bytes, |
| 1400 | PT_BYTE + combined_after_bytes); | 1423 | PT_BYTE + combined_after_bytes); |
| 1401 | record_delete (PT, deletion); | 1424 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1425 | record_delete (PT, deletion); | ||
| 1402 | } | 1426 | } |
| 1403 | 1427 | ||
| 1404 | if (combined_before_bytes) | 1428 | if (combined_before_bytes) |
| 1405 | { | 1429 | { |
| 1406 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | 1430 | Lisp_Object deletion; |
| 1407 | PT, PT_BYTE, 1); | 1431 | deletion = Qnil; |
| 1432 | |||
| 1433 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1434 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1435 | PT, PT_BYTE, 1); | ||
| 1408 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1436 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1409 | PT, PT_BYTE); | 1437 | PT, PT_BYTE); |
| 1410 | record_delete (PT - 1, deletion); | 1438 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1439 | record_delete (PT - 1, deletion); | ||
| 1411 | } | 1440 | } |
| 1412 | 1441 | ||
| 1413 | record_insert (PT - !!combined_before_bytes, | 1442 | record_insert (PT - !!combined_before_bytes, |
| @@ -1474,12 +1503,17 @@ adjust_before_replace (from, from_byte, to, to_byte) | |||
| 1474 | int from, from_byte, to, to_byte; | 1503 | int from, from_byte, to, to_byte; |
| 1475 | { | 1504 | { |
| 1476 | Lisp_Object deletion; | 1505 | Lisp_Object deletion; |
| 1477 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | 1506 | |
| 1507 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1508 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | ||
| 1478 | 1509 | ||
| 1479 | CHECK_MARKERS (); | 1510 | CHECK_MARKERS (); |
| 1480 | 1511 | ||
| 1481 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1512 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1482 | record_delete (from, deletion); | 1513 | |
| 1514 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1515 | record_delete (from, deletion); | ||
| 1516 | |||
| 1483 | adjust_overlays_for_delete (from, to - from); | 1517 | adjust_overlays_for_delete (from, to - from); |
| 1484 | } | 1518 | } |
| 1485 | 1519 | ||
| @@ -1499,28 +1533,39 @@ adjust_after_replace (from, from_byte, prev_text, len, len_byte) | |||
| 1499 | = count_combining_before (GPT_ADDR, len_byte, from, from_byte); | 1533 | = count_combining_before (GPT_ADDR, len_byte, from, from_byte); |
| 1500 | int combined_after_bytes | 1534 | int combined_after_bytes |
| 1501 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); | 1535 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); |
| 1502 | Lisp_Object deletion; | ||
| 1503 | int nchars_del = 0, nbytes_del = 0; | 1536 | int nchars_del = 0, nbytes_del = 0; |
| 1504 | 1537 | ||
| 1505 | if (combined_after_bytes) | 1538 | if (combined_after_bytes) |
| 1506 | { | 1539 | { |
| 1507 | deletion = make_buffer_string_both (from, from_byte, | 1540 | Lisp_Object deletion; |
| 1508 | from + combined_after_bytes, | 1541 | deletion = Qnil; |
| 1509 | from_byte + combined_after_bytes, 1); | 1542 | |
| 1543 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1544 | deletion = make_buffer_string_both (from, from_byte, | ||
| 1545 | from + combined_after_bytes, | ||
| 1546 | from_byte + combined_after_bytes, | ||
| 1547 | 1); | ||
| 1510 | 1548 | ||
| 1511 | adjust_markers_for_record_delete (from, from_byte, | 1549 | adjust_markers_for_record_delete (from, from_byte, |
| 1512 | from + combined_after_bytes, | 1550 | from + combined_after_bytes, |
| 1513 | from_byte + combined_after_bytes); | 1551 | from_byte + combined_after_bytes); |
| 1514 | record_delete (from, deletion); | 1552 | |
| 1553 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1554 | record_delete (from, deletion); | ||
| 1515 | } | 1555 | } |
| 1516 | 1556 | ||
| 1517 | if (combined_before_bytes) | 1557 | if (combined_before_bytes) |
| 1518 | { | 1558 | { |
| 1519 | deletion = make_buffer_string_both (from - 1, CHAR_TO_BYTE (from - 1), | 1559 | Lisp_Object deletion; |
| 1520 | from, from_byte, 1); | 1560 | deletion = Qnil; |
| 1561 | |||
| 1562 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1563 | deletion = make_buffer_string_both (from - 1, CHAR_TO_BYTE (from - 1), | ||
| 1564 | from, from_byte, 1); | ||
| 1521 | adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1), | 1565 | adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1), |
| 1522 | from, from_byte); | 1566 | from, from_byte); |
| 1523 | record_delete (from - 1, deletion); | 1567 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1568 | record_delete (from - 1, deletion); | ||
| 1524 | } | 1569 | } |
| 1525 | 1570 | ||
| 1526 | /* Update various buffer positions for the new text. */ | 1571 | /* Update various buffer positions for the new text. */ |
| @@ -1624,7 +1669,6 @@ replace_range (from, to, new, prepare, inherit, nomarkers) | |||
| 1624 | int adjusted_inschars; | 1669 | int adjusted_inschars; |
| 1625 | INTERVAL intervals; | 1670 | INTERVAL intervals; |
| 1626 | int outgoing_insbytes = insbytes; | 1671 | int outgoing_insbytes = insbytes; |
| 1627 | Lisp_Object deletion; | ||
| 1628 | 1672 | ||
| 1629 | CHECK_MARKERS (); | 1673 | CHECK_MARKERS (); |
| 1630 | 1674 | ||
| @@ -1676,16 +1720,23 @@ replace_range (from, to, new, prepare, inherit, nomarkers) | |||
| 1676 | if (to < GPT) | 1720 | if (to < GPT) |
| 1677 | gap_left (to, to_byte, 0); | 1721 | gap_left (to, to_byte, 0); |
| 1678 | 1722 | ||
| 1679 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | 1723 | { |
| 1724 | Lisp_Object deletion; | ||
| 1725 | deletion = Qnil; | ||
| 1726 | |||
| 1727 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1728 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | ||
| 1680 | 1729 | ||
| 1681 | if (nomarkers) | 1730 | if (nomarkers) |
| 1682 | /* Relocate all markers pointing into the new, larger gap | 1731 | /* Relocate all markers pointing into the new, larger gap |
| 1683 | to point at the end of the text before the gap. | 1732 | to point at the end of the text before the gap. |
| 1684 | Do this before recording the deletion, | 1733 | Do this before recording the deletion, |
| 1685 | so that undo handles this after reinserting the text. */ | 1734 | so that undo handles this after reinserting the text. */ |
| 1686 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1735 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1687 | 1736 | ||
| 1688 | record_delete (from, deletion); | 1737 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1738 | record_delete (from, deletion); | ||
| 1739 | } | ||
| 1689 | 1740 | ||
| 1690 | GAP_SIZE += nbytes_del; | 1741 | GAP_SIZE += nbytes_del; |
| 1691 | ZV -= nchars_del; | 1742 | ZV -= nchars_del; |
| @@ -1733,23 +1784,33 @@ replace_range (from, to, new, prepare, inherit, nomarkers) | |||
| 1733 | 1784 | ||
| 1734 | if (combined_after_bytes) | 1785 | if (combined_after_bytes) |
| 1735 | { | 1786 | { |
| 1736 | deletion = make_buffer_string_both (PT, PT_BYTE, | 1787 | Lisp_Object deletion; |
| 1737 | PT + combined_after_bytes, | 1788 | deletion = Qnil; |
| 1738 | PT_BYTE + combined_after_bytes, 1); | 1789 | |
| 1790 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1791 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1792 | PT + combined_after_bytes, | ||
| 1793 | PT_BYTE + combined_after_bytes, 1); | ||
| 1739 | 1794 | ||
| 1740 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1795 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1741 | PT + combined_after_bytes, | 1796 | PT + combined_after_bytes, |
| 1742 | PT_BYTE + combined_after_bytes); | 1797 | PT_BYTE + combined_after_bytes); |
| 1743 | record_delete (PT, deletion); | 1798 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1799 | record_delete (PT, deletion); | ||
| 1744 | } | 1800 | } |
| 1745 | 1801 | ||
| 1746 | if (combined_before_bytes) | 1802 | if (combined_before_bytes) |
| 1747 | { | 1803 | { |
| 1748 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | 1804 | Lisp_Object deletion; |
| 1749 | PT, PT_BYTE, 1); | 1805 | deletion = Qnil; |
| 1806 | |||
| 1807 | if (! EQ (current_buffer->undo_list, Qt)) | ||
| 1808 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1809 | PT, PT_BYTE, 1); | ||
| 1750 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1810 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1751 | PT, PT_BYTE); | 1811 | PT, PT_BYTE); |
| 1752 | record_delete (PT - 1, deletion); | 1812 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1813 | record_delete (PT - 1, deletion); | ||
| 1753 | } | 1814 | } |
| 1754 | 1815 | ||
| 1755 | record_insert (PT - !!combined_before_bytes, | 1816 | record_insert (PT - !!combined_before_bytes, |
| @@ -1966,11 +2027,12 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1966 | else | 2027 | else |
| 1967 | from_byte_1 = from_byte; | 2028 | from_byte_1 = from_byte; |
| 1968 | 2029 | ||
| 1969 | deletion | 2030 | if (! EQ (current_buffer->undo_list, Qt)) |
| 1970 | = make_buffer_string_both (from - !!combined_after_bytes, | 2031 | deletion |
| 1971 | from_byte_1, | 2032 | = make_buffer_string_both (from - !!combined_after_bytes, |
| 1972 | to + combined_after_bytes, | 2033 | from_byte_1, |
| 1973 | to_byte + combined_after_bytes, 1); | 2034 | to + combined_after_bytes, |
| 2035 | to_byte + combined_after_bytes, 1); | ||
| 1974 | if (combined_after_bytes) | 2036 | if (combined_after_bytes) |
| 1975 | /* COMBINED_AFTER_BYTES nonzero means that the above code moved | 2037 | /* COMBINED_AFTER_BYTES nonzero means that the above code moved |
| 1976 | the gap. We must move the gap again to a proper place. */ | 2038 | the gap. We must move the gap again to a proper place. */ |
| @@ -1997,7 +2059,8 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1997 | adjust_markers_for_record_delete (from - 1, from_byte_1, | 2059 | adjust_markers_for_record_delete (from - 1, from_byte_1, |
| 1998 | from, from_byte); | 2060 | from, from_byte); |
| 1999 | } | 2061 | } |
| 2000 | record_delete (from - !!combined_after_bytes, deletion); | 2062 | if (! EQ (current_buffer->undo_list, Qt)) |
| 2063 | record_delete (from - !!combined_after_bytes, deletion); | ||
| 2001 | MODIFF++; | 2064 | MODIFF++; |
| 2002 | 2065 | ||
| 2003 | /* Relocate point as if it were a marker. */ | 2066 | /* Relocate point as if it were a marker. */ |