Mercurial > emacs
comparison src/insdel.c @ 21228:31a2889105f0
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 20 Mar 1998 06:10:36 +0000 |
parents | b4e925500a71 |
children | 90e90245e679 |
comparison
equal
deleted
inserted
replaced
21227:be147fbd56f1 | 21228:31a2889105f0 |
---|---|
38 static void gap_left P_ ((int, int, int)); | 38 static void gap_left P_ ((int, int, int)); |
39 static void gap_right P_ ((int, int)); | 39 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 (); |
46 | 47 |
47 /* Non-nil means don't call the after-change-functions right away, | 48 /* Non-nil means don't call the after-change-functions right away, |
337 register int from, from_byte, to, to_byte; | 338 register int from, from_byte, to, to_byte; |
338 { | 339 { |
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 |
347 while (!NILP (marker)) | 346 while (!NILP (marker)) |
348 { | 347 { |
365 { | 364 { |
366 record_marker_adjustment (marker, from - charpos); | 365 record_marker_adjustment (marker, from - charpos); |
367 m->charpos = from; | 366 m->charpos = from; |
368 m->bytepos = from_byte; | 367 m->bytepos = from_byte; |
369 } | 368 } |
369 | |
370 marker = m->chain; | |
371 } | |
372 } | |
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); | |
370 | 400 |
371 marker = m->chain; | 401 marker = m->chain; |
372 } | 402 } |
373 } | 403 } |
374 | 404 |
918 | 948 |
919 But there is no need to actually delete the combining bytes | 949 But there is no need to actually delete the combining bytes |
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); |
930 MODIFF++; | 969 MODIFF++; |
931 | 970 |
1089 | 1128 |
1090 But there is no need to actually delete the combining bytes | 1129 But there is no need to actually delete the combining bytes |
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); |
1101 MODIFF++; | 1149 MODIFF++; |
1102 | 1150 |
1245 | 1293 |
1246 But there is no need to actually delete the combining bytes | 1294 But there is no need to actually delete the combining bytes |
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); |
1257 MODIFF++; | 1314 MODIFF++; |
1258 | 1315 |
1332 = count_combining_before (GPT_ADDR, len_byte, from, from_byte); | 1389 = count_combining_before (GPT_ADDR, len_byte, from, from_byte); |
1333 int combined_after_bytes | 1390 int combined_after_bytes |
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; |
1344 ZV += len; Z+= len; | 1410 ZV += len; Z+= len; |
1345 ZV_BYTE += len_byte; Z_BYTE += len_byte; | 1411 ZV_BYTE += len_byte; Z_BYTE += len_byte; |
1515 | 1581 |
1516 But there is no need to actually delete the combining bytes | 1582 But there is no need to actually delete the combining bytes |
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); |
1527 | 1602 |
1528 GAP_SIZE -= outgoing_insbytes; | 1603 GAP_SIZE -= outgoing_insbytes; |
1725 /* Relocate all markers pointing into the new, larger gap | 1800 /* Relocate all markers pointing into the new, larger gap |
1726 to point at the end of the text before the gap. | 1801 to point at the end of the text before the gap. |
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 |
1736 gap again to a proper place. */ | 1830 gap again to a proper place. */ |
1737 move_gap_both (from, from_byte); | 1831 move_gap_both (from, from_byte); |
1770 beg_unchanged = GPT - BEG; | 1864 beg_unchanged = GPT - BEG; |
1771 if (Z - GPT < end_unchanged) | 1865 if (Z - GPT < end_unchanged) |
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 { |
1776 | 1870 combine_bytes (from, from_byte, combined_after_bytes); |
1777 if (combined_after_bytes) | 1871 |
1778 record_insert (GPT - 1, 1); | 1872 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); |
1782 } | 1877 } |
1783 | 1878 |