diff options
| author | Richard M. Stallman | 1998-03-21 03:57:35 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-21 03:57:35 +0000 |
| commit | 628cea90f17ce967f78be99c55ac351b1d939e14 (patch) | |
| tree | 4d0a697c6b44e735288ba2fc5a7e54acfc30b069 /src | |
| parent | 88441c8eb8fab886944322aa94ae799ba92c8193 (diff) | |
| download | emacs-628cea90f17ce967f78be99c55ac351b1d939e14.tar.gz emacs-628cea90f17ce967f78be99c55ac351b1d939e14.zip | |
(insert_1_both, insert_from_string_1, insert_from_buffer_1):
(adjust_before_replace, adjust_after_replace, replace_range):
(del_range_2): Call record_delete the new way.
Use make_buffer_string_both to make the string to pass.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 87 |
1 files changed, 68 insertions, 19 deletions
diff --git a/src/insdel.c b/src/insdel.c index e86f8e1dc5c..3c76f3255dc 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -923,7 +923,7 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | |||
| 923 | register int nchars, nbytes; | 923 | register int nchars, nbytes; |
| 924 | int inherit, prepare, before_markers; | 924 | int inherit, prepare, before_markers; |
| 925 | { | 925 | { |
| 926 | register Lisp_Object temp; | 926 | register Lisp_Object temp, deletion; |
| 927 | int combined_before_bytes, combined_after_bytes; | 927 | int combined_before_bytes, combined_after_bytes; |
| 928 | 928 | ||
| 929 | if (NILP (current_buffer->enable_multibyte_characters)) | 929 | if (NILP (current_buffer->enable_multibyte_characters)) |
| @@ -951,17 +951,23 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | |||
| 951 | 951 | ||
| 952 | if (combined_after_bytes) | 952 | if (combined_after_bytes) |
| 953 | { | 953 | { |
| 954 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 955 | PT + combined_after_bytes, | ||
| 956 | PT_BYTE + combined_after_bytes, 1); | ||
| 957 | |||
| 954 | adjust_markers_for_record_delete (PT, PT_BYTE, | 958 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 955 | PT + combined_after_bytes, | 959 | PT + combined_after_bytes, |
| 956 | PT_BYTE + combined_after_bytes); | 960 | PT_BYTE + combined_after_bytes); |
| 957 | record_delete (PT, combined_after_bytes); | 961 | record_delete (PT, deletion); |
| 958 | } | 962 | } |
| 959 | 963 | ||
| 960 | if (combined_before_bytes) | 964 | if (combined_before_bytes) |
| 961 | { | 965 | { |
| 966 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 967 | PT, PT_BYTE, 1); | ||
| 962 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 968 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 963 | PT, PT_BYTE); | 969 | PT, PT_BYTE); |
| 964 | record_delete (PT - 1, 1); | 970 | record_delete (PT - 1, deletion); |
| 965 | } | 971 | } |
| 966 | 972 | ||
| 967 | record_insert (PT - !!combined_before_bytes, | 973 | record_insert (PT - !!combined_before_bytes, |
| @@ -1076,6 +1082,7 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1076 | int combined_before_bytes, combined_after_bytes; | 1082 | int combined_before_bytes, combined_after_bytes; |
| 1077 | int adjusted_nchars; | 1083 | int adjusted_nchars; |
| 1078 | INTERVAL intervals; | 1084 | INTERVAL intervals; |
| 1085 | Lisp_Object deletion; | ||
| 1079 | 1086 | ||
| 1080 | /* Make OUTGOING_NBYTES describe the text | 1087 | /* Make OUTGOING_NBYTES describe the text |
| 1081 | as it will be inserted in this buffer. */ | 1088 | as it will be inserted in this buffer. */ |
| @@ -1131,17 +1138,23 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1131 | 1138 | ||
| 1132 | if (combined_after_bytes) | 1139 | if (combined_after_bytes) |
| 1133 | { | 1140 | { |
| 1141 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1142 | PT + combined_after_bytes, | ||
| 1143 | PT_BYTE + combined_after_bytes, 1); | ||
| 1144 | |||
| 1134 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1145 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1135 | PT + combined_after_bytes, | 1146 | PT + combined_after_bytes, |
| 1136 | PT_BYTE + combined_after_bytes); | 1147 | PT_BYTE + combined_after_bytes); |
| 1137 | record_delete (PT, combined_after_bytes); | 1148 | record_delete (PT, deletion); |
| 1138 | } | 1149 | } |
| 1139 | 1150 | ||
| 1140 | if (combined_before_bytes) | 1151 | if (combined_before_bytes) |
| 1141 | { | 1152 | { |
| 1153 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1154 | PT, PT_BYTE, 1); | ||
| 1142 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1155 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1143 | PT, PT_BYTE); | 1156 | PT, PT_BYTE); |
| 1144 | record_delete (PT - 1, 1); | 1157 | record_delete (PT - 1, deletion); |
| 1145 | } | 1158 | } |
| 1146 | 1159 | ||
| 1147 | record_insert (PT - !!combined_before_bytes, | 1160 | record_insert (PT - !!combined_before_bytes, |
| @@ -1226,7 +1239,7 @@ insert_from_buffer_1 (buf, from, nchars, inherit) | |||
| 1226 | int from, nchars; | 1239 | int from, nchars; |
| 1227 | int inherit; | 1240 | int inherit; |
| 1228 | { | 1241 | { |
| 1229 | register Lisp_Object temp; | 1242 | register Lisp_Object temp, deletion; |
| 1230 | int chunk; | 1243 | int chunk; |
| 1231 | int from_byte = buf_charpos_to_bytepos (buf, from); | 1244 | int from_byte = buf_charpos_to_bytepos (buf, from); |
| 1232 | int to_byte = buf_charpos_to_bytepos (buf, from + nchars); | 1245 | int to_byte = buf_charpos_to_bytepos (buf, from + nchars); |
| @@ -1296,17 +1309,23 @@ insert_from_buffer_1 (buf, from, nchars, inherit) | |||
| 1296 | 1309 | ||
| 1297 | if (combined_after_bytes) | 1310 | if (combined_after_bytes) |
| 1298 | { | 1311 | { |
| 1312 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1313 | PT + combined_after_bytes, | ||
| 1314 | PT_BYTE + combined_after_bytes, 1); | ||
| 1315 | |||
| 1299 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1316 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1300 | PT + combined_after_bytes, | 1317 | PT + combined_after_bytes, |
| 1301 | PT_BYTE + combined_after_bytes); | 1318 | PT_BYTE + combined_after_bytes); |
| 1302 | record_delete (PT, combined_after_bytes); | 1319 | record_delete (PT, deletion); |
| 1303 | } | 1320 | } |
| 1304 | 1321 | ||
| 1305 | if (combined_before_bytes) | 1322 | if (combined_before_bytes) |
| 1306 | { | 1323 | { |
| 1324 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1325 | PT, PT_BYTE, 1); | ||
| 1307 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1326 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1308 | PT, PT_BYTE); | 1327 | PT, PT_BYTE); |
| 1309 | record_delete (PT - 1, 1); | 1328 | record_delete (PT - 1, deletion); |
| 1310 | } | 1329 | } |
| 1311 | 1330 | ||
| 1312 | record_insert (PT - !!combined_before_bytes, | 1331 | record_insert (PT - !!combined_before_bytes, |
| @@ -1372,8 +1391,11 @@ void | |||
| 1372 | adjust_before_replace (from, from_byte, to, to_byte) | 1391 | adjust_before_replace (from, from_byte, to, to_byte) |
| 1373 | int from, from_byte, to, to_byte; | 1392 | int from, from_byte, to, to_byte; |
| 1374 | { | 1393 | { |
| 1394 | Lisp_Object deletion; | ||
| 1395 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | ||
| 1396 | |||
| 1375 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1397 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1376 | record_delete (from, to - from); | 1398 | record_delete (from, deletion); |
| 1377 | adjust_overlays_for_delete (from, to - from); | 1399 | adjust_overlays_for_delete (from, to - from); |
| 1378 | } | 1400 | } |
| 1379 | 1401 | ||
| @@ -1389,20 +1411,27 @@ adjust_after_replace (from, from_byte, to, to_byte, len, len_byte, replace) | |||
| 1389 | = count_combining_before (GPT_ADDR, len_byte, from, from_byte); | 1411 | = count_combining_before (GPT_ADDR, len_byte, from, from_byte); |
| 1390 | int combined_after_bytes | 1412 | int combined_after_bytes |
| 1391 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); | 1413 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); |
| 1414 | Lisp_Object deletion; | ||
| 1392 | 1415 | ||
| 1393 | if (combined_after_bytes) | 1416 | if (combined_after_bytes) |
| 1394 | { | 1417 | { |
| 1418 | deletion = make_buffer_string_both (from, from_byte, | ||
| 1419 | from + combined_after_bytes, | ||
| 1420 | from_byte + combined_after_bytes, 1); | ||
| 1421 | |||
| 1395 | adjust_markers_for_record_delete (from, from_byte, | 1422 | adjust_markers_for_record_delete (from, from_byte, |
| 1396 | from + combined_after_bytes, | 1423 | from + combined_after_bytes, |
| 1397 | from_byte + combined_after_bytes); | 1424 | from_byte + combined_after_bytes); |
| 1398 | record_delete (from, combined_after_bytes); | 1425 | record_delete (from, deletion); |
| 1399 | } | 1426 | } |
| 1400 | 1427 | ||
| 1401 | if (combined_before_bytes) | 1428 | if (combined_before_bytes) |
| 1402 | { | 1429 | { |
| 1430 | deletion = make_buffer_string_both (from - 1, CHAR_TO_BYTE (from - 1), | ||
| 1431 | from, from_byte, 1); | ||
| 1403 | adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1), | 1432 | adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1), |
| 1404 | from, from_byte); | 1433 | from, from_byte); |
| 1405 | record_delete (from - 1, 1); | 1434 | record_delete (from - 1, deletion); |
| 1406 | } | 1435 | } |
| 1407 | 1436 | ||
| 1408 | /* Update various buffer positions for the new text. */ | 1437 | /* Update various buffer positions for the new text. */ |
| @@ -1477,6 +1506,7 @@ replace_range (from, to, new, prepare, inherit) | |||
| 1477 | int adjusted_inschars; | 1506 | int adjusted_inschars; |
| 1478 | INTERVAL intervals; | 1507 | INTERVAL intervals; |
| 1479 | int outgoing_insbytes = insbytes; | 1508 | int outgoing_insbytes = insbytes; |
| 1509 | Lisp_Object deletion; | ||
| 1480 | 1510 | ||
| 1481 | GCPRO1 (new); | 1511 | GCPRO1 (new); |
| 1482 | 1512 | ||
| @@ -1526,13 +1556,15 @@ replace_range (from, to, new, prepare, inherit) | |||
| 1526 | if (to < GPT) | 1556 | if (to < GPT) |
| 1527 | gap_left (to, to_byte, 0); | 1557 | gap_left (to, to_byte, 0); |
| 1528 | 1558 | ||
| 1559 | deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | ||
| 1560 | |||
| 1529 | /* Relocate all markers pointing into the new, larger gap | 1561 | /* Relocate all markers pointing into the new, larger gap |
| 1530 | to point at the end of the text before the gap. | 1562 | to point at the end of the text before the gap. |
| 1531 | Do this before recording the deletion, | 1563 | Do this before recording the deletion, |
| 1532 | so that undo handles this after reinserting the text. */ | 1564 | so that undo handles this after reinserting the text. */ |
| 1533 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1565 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1534 | 1566 | ||
| 1535 | record_delete (from, nchars_del); | 1567 | record_delete (from, deletion); |
| 1536 | 1568 | ||
| 1537 | GAP_SIZE += nbytes_del; | 1569 | GAP_SIZE += nbytes_del; |
| 1538 | ZV -= nchars_del; | 1570 | ZV -= nchars_del; |
| @@ -1584,17 +1616,23 @@ replace_range (from, to, new, prepare, inherit) | |||
| 1584 | 1616 | ||
| 1585 | if (combined_after_bytes) | 1617 | if (combined_after_bytes) |
| 1586 | { | 1618 | { |
| 1619 | deletion = make_buffer_string_both (PT, PT_BYTE, | ||
| 1620 | PT + combined_after_bytes, | ||
| 1621 | PT_BYTE + combined_after_bytes, 1); | ||
| 1622 | |||
| 1587 | adjust_markers_for_record_delete (PT, PT_BYTE, | 1623 | adjust_markers_for_record_delete (PT, PT_BYTE, |
| 1588 | PT + combined_after_bytes, | 1624 | PT + combined_after_bytes, |
| 1589 | PT_BYTE + combined_after_bytes); | 1625 | PT_BYTE + combined_after_bytes); |
| 1590 | record_delete (PT, combined_after_bytes); | 1626 | record_delete (PT, deletion); |
| 1591 | } | 1627 | } |
| 1592 | 1628 | ||
| 1593 | if (combined_before_bytes) | 1629 | if (combined_before_bytes) |
| 1594 | { | 1630 | { |
| 1631 | deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1632 | PT, PT_BYTE, 1); | ||
| 1595 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | 1633 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), |
| 1596 | PT, PT_BYTE); | 1634 | PT, PT_BYTE); |
| 1597 | record_delete (PT - 1, 1); | 1635 | record_delete (PT - 1, deletion); |
| 1598 | } | 1636 | } |
| 1599 | 1637 | ||
| 1600 | record_insert (PT - !!combined_before_bytes, | 1638 | record_insert (PT - !!combined_before_bytes, |
| @@ -1783,6 +1821,8 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1783 | { | 1821 | { |
| 1784 | register int nbytes_del, nchars_del; | 1822 | register int nbytes_del, nchars_del; |
| 1785 | int combined_after_bytes; | 1823 | int combined_after_bytes; |
| 1824 | Lisp_Object deletion; | ||
| 1825 | int from_byte_1; | ||
| 1786 | 1826 | ||
| 1787 | nchars_del = to - from; | 1827 | nchars_del = to - from; |
| 1788 | nbytes_del = to_byte - from_byte; | 1828 | nbytes_del = to_byte - from_byte; |
| @@ -1796,6 +1836,19 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1796 | combined_after_bytes | 1836 | combined_after_bytes |
| 1797 | = count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte), | 1837 | = count_combining_before (BUF_BYTE_ADDRESS (current_buffer, to_byte), |
| 1798 | ZV_BYTE - to_byte, from, from_byte); | 1838 | ZV_BYTE - to_byte, from, from_byte); |
| 1839 | if (combined_after_bytes) | ||
| 1840 | { | ||
| 1841 | from_byte_1 = from_byte; | ||
| 1842 | DEC_POS (from_byte_1); | ||
| 1843 | } | ||
| 1844 | else | ||
| 1845 | from_byte_1 = from_byte; | ||
| 1846 | |||
| 1847 | deletion | ||
| 1848 | = make_buffer_string_both (from - !!combined_after_bytes, | ||
| 1849 | from_byte_1, | ||
| 1850 | to + combined_after_bytes, | ||
| 1851 | to_byte + combined_after_bytes, 1); | ||
| 1799 | 1852 | ||
| 1800 | /* Relocate all markers pointing into the new, larger gap | 1853 | /* Relocate all markers pointing into the new, larger gap |
| 1801 | to point at the end of the text before the gap. | 1854 | to point at the end of the text before the gap. |
| @@ -1804,9 +1857,6 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1804 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1857 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1805 | if (combined_after_bytes) | 1858 | if (combined_after_bytes) |
| 1806 | { | 1859 | { |
| 1807 | int from_byte_1 = from_byte; | ||
| 1808 | DEC_POS (from_byte_1); | ||
| 1809 | |||
| 1810 | /* Adjust markers for the phony deletion | 1860 | /* Adjust markers for the phony deletion |
| 1811 | that we are about to call record_undo for. */ | 1861 | that we are about to call record_undo for. */ |
| 1812 | 1862 | ||
| @@ -1821,8 +1871,7 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1821 | adjust_markers_for_record_delete (from - 1, from_byte_1, | 1871 | adjust_markers_for_record_delete (from - 1, from_byte_1, |
| 1822 | from, from_byte); | 1872 | from, from_byte); |
| 1823 | } | 1873 | } |
| 1824 | record_delete (from - !!combined_after_bytes, | 1874 | record_delete (from - !!combined_after_bytes, deletion); |
| 1825 | nchars_del + combined_after_bytes + !!combined_after_bytes); | ||
| 1826 | 1875 | ||
| 1827 | if (combined_after_bytes) | 1876 | if (combined_after_bytes) |
| 1828 | /* COMBINED_AFTER_BYTES nonzero means that the above record_delete | 1877 | /* COMBINED_AFTER_BYTES nonzero means that the above record_delete |