aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-09-16 07:21:31 +0000
committerKenichi Handa1998-09-16 07:21:31 +0000
commit23b20a7066f96cc984b0d58ccf96dad03850c7de (patch)
treea2292fba65cf26b3a0a9fa566c763e800adccdf4 /src
parentf2558efdddf27108eedfd9f24f9ffb5414599c43 (diff)
downloademacs-23b20a7066f96cc984b0d58ccf96dad03850c7de.tar.gz
emacs-23b20a7066f96cc984b0d58ccf96dad03850c7de.zip
(adjust_markers_for_replace): Don't adjust a byte
position if it is FROM. (adjust_markers_for_combining): New function. (combine_bytes): Call adjust_markers_for_combining instead of adjust_markers_for_replace. (adjust_after_replace): Record deletion of combining after bytes with the correct position. Don't add combining bytes to the args given to adjust_point. Handle correctly the case that there are both before and after combining bytes. (replace_range): Likewise. Record the actual deletion after recoding deletions of combining bytes.
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c87
1 files changed, 59 insertions, 28 deletions
diff --git a/src/insdel.c b/src/insdel.c
index d942da1f155..60cfefd1af7 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -400,6 +400,45 @@ adjust_markers_for_delete (from, from_byte, to, to_byte)
400 marker = m->chain; 400 marker = m->chain;
401 } 401 }
402} 402}
403
404/* Adjust all markers for a byte combining of NBYTES at char position
405 FROM and byte position FROM_BYTE. */
406
407static void
408adjust_markers_for_combining (from, from_byte, nbytes)
409 register int from, from_byte, nbytes;
410{
411 Lisp_Object marker;
412 register struct Lisp_Marker *m;
413 register int bytepos;
414 register int to_byte = from_byte + nbytes;
415
416 marker = BUF_MARKERS (current_buffer);
417
418 while (!NILP (marker))
419 {
420 m = XMARKER (marker);
421 bytepos = m->bytepos;
422
423 if (bytepos >= to_byte)
424 {
425 record_marker_adjustment (marker, - nbytes);
426 m->charpos -= nbytes;
427 }
428 else if (bytepos > from_byte)
429 {
430 record_marker_adjustment (marker, from - m->charpos);
431 m->charpos = from;
432 m->bytepos = to_byte;
433 }
434 else if (bytepos == from_byte)
435 {
436 m->bytepos = to_byte;
437 }
438
439 marker = m->chain;
440 }
441}
403 442
404/* Adjust all markers for calling record_delete for combining bytes. 443/* Adjust all markers for calling record_delete for combining bytes.
405 whose range in bytes is FROM_BYTE to TO_BYTE. 444 whose range in bytes is FROM_BYTE to TO_BYTE.
@@ -595,14 +634,6 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
595 m->charpos = from; 634 m->charpos = from;
596 m->bytepos = from_byte; 635 m->bytepos = from_byte;
597 } 636 }
598 else if (m->bytepos == from_byte)
599 {
600 if (combined_before_bytes)
601 {
602 DEC_BOTH (m->charpos, m->bytepos);
603 INC_BOTH (m->charpos, m->bytepos);
604 }
605 }
606 637
607 marker = m->chain; 638 marker = m->chain;
608 } 639 }
@@ -1013,7 +1044,7 @@ combine_bytes (pos, pos_byte, nbytes)
1013 int pos, pos_byte, nbytes; 1044 int pos, pos_byte, nbytes;
1014{ 1045{
1015 /* Adjust all markers. */ 1046 /* Adjust all markers. */
1016 adjust_markers_for_delete (pos, pos_byte, pos + nbytes, pos_byte); 1047 adjust_markers_for_combining (pos, pos_byte, nbytes);
1017 1048
1018 adjust_overlays_for_delete (pos, nbytes); 1049 adjust_overlays_for_delete (pos, nbytes);
1019 1050
@@ -1576,7 +1607,7 @@ adjust_after_replace (from, from_byte, prev_text, len, len_byte)
1576 from_byte + combined_after_bytes); 1607 from_byte + combined_after_bytes);
1577 1608
1578 if (! EQ (current_buffer->undo_list, Qt)) 1609 if (! EQ (current_buffer->undo_list, Qt))
1579 record_delete (from, deletion); 1610 record_delete (from + len, deletion);
1580 } 1611 }
1581 1612
1582 if (combined_before_bytes) 1613 if (combined_before_bytes)
@@ -1705,6 +1736,7 @@ replace_range (from, to, new, prepare, inherit, markers)
1705 int adjusted_inschars; 1736 int adjusted_inschars;
1706 INTERVAL intervals; 1737 INTERVAL intervals;
1707 int outgoing_insbytes = insbytes; 1738 int outgoing_insbytes = insbytes;
1739 Lisp_Object deletion;
1708 1740
1709 CHECK_MARKERS (); 1741 CHECK_MARKERS ();
1710 1742
@@ -1756,23 +1788,17 @@ replace_range (from, to, new, prepare, inherit, markers)
1756 if (to < GPT) 1788 if (to < GPT)
1757 gap_left (to, to_byte, 0); 1789 gap_left (to, to_byte, 0);
1758 1790
1759 { 1791 deletion = Qnil;
1760 Lisp_Object deletion;
1761 deletion = Qnil;
1762
1763 if (! EQ (current_buffer->undo_list, Qt))
1764 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1);
1765 1792
1766 if (markers) 1793 if (! EQ (current_buffer->undo_list, Qt))
1767 /* Relocate all markers pointing into the new, larger gap 1794 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1);
1768 to point at the end of the text before the gap.
1769 Do this before recording the deletion,
1770 so that undo handles this after reinserting the text. */
1771 adjust_markers_for_delete (from, from_byte, to, to_byte);
1772 1795
1773 if (! EQ (current_buffer->undo_list, Qt)) 1796 if (markers)
1774 record_delete (from, deletion); 1797 /* Relocate all markers pointing into the new, larger gap
1775 } 1798 to point at the end of the text before the gap.
1799 Do this before recording the deletion,
1800 so that undo handles this after reinserting the text. */
1801 adjust_markers_for_delete (from, from_byte, to, to_byte);
1776 1802
1777 GAP_SIZE += nbytes_del; 1803 GAP_SIZE += nbytes_del;
1778 ZV -= nchars_del; 1804 ZV -= nchars_del;
@@ -1832,7 +1858,7 @@ replace_range (from, to, new, prepare, inherit, markers)
1832 from + combined_after_bytes, 1858 from + combined_after_bytes,
1833 from_byte + combined_after_bytes); 1859 from_byte + combined_after_bytes);
1834 if (! EQ (current_buffer->undo_list, Qt)) 1860 if (! EQ (current_buffer->undo_list, Qt))
1835 record_delete (from, deletion); 1861 record_delete (from + inschars, deletion);
1836 } 1862 }
1837 1863
1838 if (combined_before_bytes) 1864 if (combined_before_bytes)
@@ -1849,8 +1875,13 @@ replace_range (from, to, new, prepare, inherit, markers)
1849 record_delete (from - 1, deletion); 1875 record_delete (from - 1, deletion);
1850 } 1876 }
1851 1877
1852 record_insert (from - !!combined_before_bytes, 1878 if (! EQ (current_buffer->undo_list, Qt))
1853 inschars - combined_before_bytes + !!combined_before_bytes); 1879 {
1880 record_delete (from - !!combined_before_bytes, deletion);
1881 record_insert (from - !!combined_before_bytes,
1882 (inschars - combined_before_bytes
1883 + !!combined_before_bytes));
1884 }
1854 1885
1855 GAP_SIZE -= outgoing_insbytes; 1886 GAP_SIZE -= outgoing_insbytes;
1856 GPT += inschars; 1887 GPT += inschars;