diff options
| author | Richard M. Stallman | 1998-03-20 06:10:36 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-20 06:10:36 +0000 |
| commit | 7cc3983fcb51a92b4bf4d4e0a18a9c28c6afd7af (patch) | |
| tree | cc260efd29f7fd5172af22869865ca0b8b34c831 /src | |
| parent | 171d003c941179671d147c50db9ba87b49e4a9f6 (diff) | |
| download | emacs-7cc3983fcb51a92b4bf4d4e0a18a9c28c6afd7af.tar.gz emacs-7cc3983fcb51a92b4bf4d4e0a18a9c28c6afd7af.zip | |
(del_range_2): Use adjust_markers_for_record_delete.
(adjust_markers_for_delete): Delete unused local coming_gap_size.
(adjust_markers_for_record_delete): New function.
(insert_1_both, insert_from_string_1, insert_from_buffer_1)
(adjust_after_replace, replace_range):
Use adjust_markers_for_record_delete.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 127 |
1 files changed, 111 insertions, 16 deletions
diff --git a/src/insdel.c b/src/insdel.c index fa40da76160..e86f8e1dc5c 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -40,6 +40,7 @@ static void gap_right P_ ((int, int)); | |||
| 40 | static void adjust_markers_gap_motion P_ ((int, int, int)); | 40 | static void adjust_markers_gap_motion P_ ((int, int, int)); |
| 41 | static void adjust_markers_for_insert P_ ((int, int, int, int, int, int, int)); | 41 | static void adjust_markers_for_insert P_ ((int, int, int, int, int, int, int)); |
| 42 | static void adjust_markers_for_delete P_ ((int, int, int, int)); | 42 | static void adjust_markers_for_delete P_ ((int, int, int, int)); |
| 43 | static void adjust_markers_for_record_delete P_ ((int, int, int, int)); | ||
| 43 | static void adjust_point P_ ((int, int)); | 44 | static void adjust_point P_ ((int, int)); |
| 44 | 45 | ||
| 45 | Lisp_Object Fcombine_after_change_execute (); | 46 | Lisp_Object Fcombine_after_change_execute (); |
| @@ -339,8 +340,6 @@ adjust_markers_for_delete (from, from_byte, to, to_byte) | |||
| 339 | Lisp_Object marker; | 340 | Lisp_Object marker; |
| 340 | register struct Lisp_Marker *m; | 341 | register struct Lisp_Marker *m; |
| 341 | register int charpos; | 342 | register int charpos; |
| 342 | /* This is what GAP_SIZE will be when this deletion is finished. */ | ||
| 343 | int coming_gap_size = GAP_SIZE + to_byte - from_byte; | ||
| 344 | 343 | ||
| 345 | marker = BUF_MARKERS (current_buffer); | 344 | marker = BUF_MARKERS (current_buffer); |
| 346 | 345 | ||
| @@ -372,6 +371,37 @@ adjust_markers_for_delete (from, from_byte, to, to_byte) | |||
| 372 | } | 371 | } |
| 373 | } | 372 | } |
| 374 | 373 | ||
| 374 | /* Adjust all markers for calling record_delete for combining bytes. | ||
| 375 | whose range in bytes is FROM_BYTE to TO_BYTE. | ||
| 376 | The range in charpos is FROM to TO. */ | ||
| 377 | |||
| 378 | static void | ||
| 379 | adjust_markers_for_record_delete (from, from_byte, to, to_byte) | ||
| 380 | register int from, from_byte, to, to_byte; | ||
| 381 | { | ||
| 382 | Lisp_Object marker; | ||
| 383 | register struct Lisp_Marker *m; | ||
| 384 | register int charpos; | ||
| 385 | |||
| 386 | marker = BUF_MARKERS (current_buffer); | ||
| 387 | |||
| 388 | while (!NILP (marker)) | ||
| 389 | { | ||
| 390 | m = XMARKER (marker); | ||
| 391 | charpos = m->charpos; | ||
| 392 | |||
| 393 | /* If the marker is after the deletion, | ||
| 394 | relocate by number of chars / bytes deleted. */ | ||
| 395 | if (charpos > to) | ||
| 396 | ; | ||
| 397 | /* Here's the case where a marker is inside text being deleted. */ | ||
| 398 | else if (charpos > from) | ||
| 399 | record_marker_adjustment (marker, from - charpos); | ||
| 400 | |||
| 401 | marker = m->chain; | ||
| 402 | } | ||
| 403 | } | ||
| 404 | |||
| 375 | /* Adjust markers for an insertion that stretches from FROM / FROM_BYTE | 405 | /* Adjust markers for an insertion that stretches from FROM / FROM_BYTE |
| 376 | to TO / TO_BYTE. We have to relocate the charpos of every marker | 406 | to TO / TO_BYTE. We have to relocate the charpos of every marker |
| 377 | that points after the insertion (but not their bytepos). | 407 | that points after the insertion (but not their bytepos). |
| @@ -920,10 +950,19 @@ insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) | |||
| 920 | from the buffer and reinsert them. */ | 950 | from the buffer and reinsert them. */ |
| 921 | 951 | ||
| 922 | if (combined_after_bytes) | 952 | if (combined_after_bytes) |
| 923 | record_delete (PT, combined_after_bytes); | 953 | { |
| 954 | adjust_markers_for_record_delete (PT, PT_BYTE, | ||
| 955 | PT + combined_after_bytes, | ||
| 956 | PT_BYTE + combined_after_bytes); | ||
| 957 | record_delete (PT, combined_after_bytes); | ||
| 958 | } | ||
| 924 | 959 | ||
| 925 | if (combined_before_bytes) | 960 | if (combined_before_bytes) |
| 926 | record_delete (PT - 1, 1); | 961 | { |
| 962 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 963 | PT, PT_BYTE); | ||
| 964 | record_delete (PT - 1, 1); | ||
| 965 | } | ||
| 927 | 966 | ||
| 928 | record_insert (PT - !!combined_before_bytes, | 967 | record_insert (PT - !!combined_before_bytes, |
| 929 | nchars - combined_before_bytes + !!combined_before_bytes); | 968 | nchars - combined_before_bytes + !!combined_before_bytes); |
| @@ -1091,10 +1130,19 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, | |||
| 1091 | from the buffer and reinsert them. */ | 1130 | from the buffer and reinsert them. */ |
| 1092 | 1131 | ||
| 1093 | if (combined_after_bytes) | 1132 | if (combined_after_bytes) |
| 1094 | record_delete (PT, combined_after_bytes); | 1133 | { |
| 1134 | adjust_markers_for_record_delete (PT, PT_BYTE, | ||
| 1135 | PT + combined_after_bytes, | ||
| 1136 | PT_BYTE + combined_after_bytes); | ||
| 1137 | record_delete (PT, combined_after_bytes); | ||
| 1138 | } | ||
| 1095 | 1139 | ||
| 1096 | if (combined_before_bytes) | 1140 | if (combined_before_bytes) |
| 1097 | record_delete (PT - 1, 1); | 1141 | { |
| 1142 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1143 | PT, PT_BYTE); | ||
| 1144 | record_delete (PT - 1, 1); | ||
| 1145 | } | ||
| 1098 | 1146 | ||
| 1099 | record_insert (PT - !!combined_before_bytes, | 1147 | record_insert (PT - !!combined_before_bytes, |
| 1100 | nchars - combined_before_bytes + !!combined_before_bytes); | 1148 | nchars - combined_before_bytes + !!combined_before_bytes); |
| @@ -1247,10 +1295,19 @@ insert_from_buffer_1 (buf, from, nchars, inherit) | |||
| 1247 | from the buffer and reinsert them. */ | 1295 | from the buffer and reinsert them. */ |
| 1248 | 1296 | ||
| 1249 | if (combined_after_bytes) | 1297 | if (combined_after_bytes) |
| 1250 | record_delete (PT, combined_after_bytes); | 1298 | { |
| 1299 | adjust_markers_for_record_delete (PT, PT_BYTE, | ||
| 1300 | PT + combined_after_bytes, | ||
| 1301 | PT_BYTE + combined_after_bytes); | ||
| 1302 | record_delete (PT, combined_after_bytes); | ||
| 1303 | } | ||
| 1251 | 1304 | ||
| 1252 | if (combined_before_bytes) | 1305 | if (combined_before_bytes) |
| 1253 | record_delete (PT - 1, 1); | 1306 | { |
| 1307 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1308 | PT, PT_BYTE); | ||
| 1309 | record_delete (PT - 1, 1); | ||
| 1310 | } | ||
| 1254 | 1311 | ||
| 1255 | record_insert (PT - !!combined_before_bytes, | 1312 | record_insert (PT - !!combined_before_bytes, |
| 1256 | nchars - combined_before_bytes + !!combined_before_bytes); | 1313 | nchars - combined_before_bytes + !!combined_before_bytes); |
| @@ -1334,10 +1391,19 @@ adjust_after_replace (from, from_byte, to, to_byte, len, len_byte, replace) | |||
| 1334 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); | 1391 | = count_combining_after (GPT_ADDR, len_byte, from, from_byte); |
| 1335 | 1392 | ||
| 1336 | if (combined_after_bytes) | 1393 | if (combined_after_bytes) |
| 1337 | record_delete (from, combined_after_bytes); | 1394 | { |
| 1395 | adjust_markers_for_record_delete (from, from_byte, | ||
| 1396 | from + combined_after_bytes, | ||
| 1397 | from_byte + combined_after_bytes); | ||
| 1398 | record_delete (from, combined_after_bytes); | ||
| 1399 | } | ||
| 1338 | 1400 | ||
| 1339 | if (combined_before_bytes) | 1401 | if (combined_before_bytes) |
| 1340 | record_delete (from - 1, 1); | 1402 | { |
| 1403 | adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1), | ||
| 1404 | from, from_byte); | ||
| 1405 | record_delete (from - 1, 1); | ||
| 1406 | } | ||
| 1341 | 1407 | ||
| 1342 | /* Update various buffer positions for the new text. */ | 1408 | /* Update various buffer positions for the new text. */ |
| 1343 | GAP_SIZE -= len_byte; | 1409 | GAP_SIZE -= len_byte; |
| @@ -1517,10 +1583,19 @@ replace_range (from, to, new, prepare, inherit) | |||
| 1517 | from the buffer and reinsert them. */ | 1583 | from the buffer and reinsert them. */ |
| 1518 | 1584 | ||
| 1519 | if (combined_after_bytes) | 1585 | if (combined_after_bytes) |
| 1520 | record_delete (PT, combined_after_bytes); | 1586 | { |
| 1587 | adjust_markers_for_record_delete (PT, PT_BYTE, | ||
| 1588 | PT + combined_after_bytes, | ||
| 1589 | PT_BYTE + combined_after_bytes); | ||
| 1590 | record_delete (PT, combined_after_bytes); | ||
| 1591 | } | ||
| 1521 | 1592 | ||
| 1522 | if (combined_before_bytes) | 1593 | if (combined_before_bytes) |
| 1523 | record_delete (PT - 1, 1); | 1594 | { |
| 1595 | adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), | ||
| 1596 | PT, PT_BYTE); | ||
| 1597 | record_delete (PT - 1, 1); | ||
| 1598 | } | ||
| 1524 | 1599 | ||
| 1525 | record_insert (PT - !!combined_before_bytes, | 1600 | record_insert (PT - !!combined_before_bytes, |
| 1526 | inschars - combined_before_bytes + !!combined_before_bytes); | 1601 | inschars - combined_before_bytes + !!combined_before_bytes); |
| @@ -1727,9 +1802,28 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1727 | Do this before recording the deletion, | 1802 | Do this before recording the deletion, |
| 1728 | so that undo handles this after reinserting the text. */ | 1803 | so that undo handles this after reinserting the text. */ |
| 1729 | adjust_markers_for_delete (from, from_byte, to, to_byte); | 1804 | adjust_markers_for_delete (from, from_byte, to, to_byte); |
| 1730 | 1805 | if (combined_after_bytes) | |
| 1806 | { | ||
| 1807 | int from_byte_1 = from_byte; | ||
| 1808 | DEC_POS (from_byte_1); | ||
| 1809 | |||
| 1810 | /* Adjust markers for the phony deletion | ||
| 1811 | that we are about to call record_undo for. */ | ||
| 1812 | |||
| 1813 | /* Here we delete the markers that formerly | ||
| 1814 | pointed at TO ... TO + COMBINED_AFTER_BYTES. | ||
| 1815 | But because of the call to adjust_markers_for_delete, above, | ||
| 1816 | they now point at FROM ... FROM + COMBINED_AFTER_BYTES. */ | ||
| 1817 | adjust_markers_for_record_delete (from, from_byte, | ||
| 1818 | from + combined_after_bytes, | ||
| 1819 | from_byte + combined_after_bytes); | ||
| 1820 | |||
| 1821 | adjust_markers_for_record_delete (from - 1, from_byte_1, | ||
| 1822 | from, from_byte); | ||
| 1823 | } | ||
| 1731 | record_delete (from - !!combined_after_bytes, | 1824 | record_delete (from - !!combined_after_bytes, |
| 1732 | nchars_del + combined_after_bytes + !!combined_after_bytes); | 1825 | nchars_del + combined_after_bytes + !!combined_after_bytes); |
| 1826 | |||
| 1733 | if (combined_after_bytes) | 1827 | if (combined_after_bytes) |
| 1734 | /* COMBINED_AFTER_BYTES nonzero means that the above record_delete | 1828 | /* COMBINED_AFTER_BYTES nonzero means that the above record_delete |
| 1735 | moved the gap by calling Fbuffer_substring. We must move the | 1829 | moved the gap by calling Fbuffer_substring. We must move the |
| @@ -1772,10 +1866,11 @@ del_range_2 (from, from_byte, to, to_byte) | |||
| 1772 | end_unchanged = Z - GPT; | 1866 | end_unchanged = Z - GPT; |
| 1773 | 1867 | ||
| 1774 | if (combined_after_bytes) | 1868 | if (combined_after_bytes) |
| 1775 | combine_bytes (from, from_byte, combined_after_bytes); | 1869 | { |
| 1870 | combine_bytes (from, from_byte, combined_after_bytes); | ||
| 1776 | 1871 | ||
| 1777 | if (combined_after_bytes) | 1872 | record_insert (GPT - 1, 1); |
| 1778 | record_insert (GPT - 1, 1); | 1873 | } |
| 1779 | 1874 | ||
| 1780 | evaporate_overlays (from); | 1875 | evaporate_overlays (from); |
| 1781 | signal_after_change (from, nchars_del, 0); | 1876 | signal_after_change (from, nchars_del, 0); |