comparison src/insdel.c @ 22896:6d368c9a689e

(replace_range): Don't assume PT is at the place where the change is being done.
author Richard M. Stallman <rms@gnu.org>
date Mon, 03 Aug 1998 22:25:54 +0000
parents 8c063663a19d
children 2e93e3302328
comparison
equal deleted inserted replaced
22895:9f800ebc6091 22896:6d368c9a689e
1786 between single-byte and multibyte. */ 1786 between single-byte and multibyte. */
1787 copy_text (XSTRING (new)->data, GPT_ADDR, insbytes, 1787 copy_text (XSTRING (new)->data, GPT_ADDR, insbytes,
1788 STRING_MULTIBYTE (new), 1788 STRING_MULTIBYTE (new),
1789 ! NILP (current_buffer->enable_multibyte_characters)); 1789 ! NILP (current_buffer->enable_multibyte_characters));
1790 1790
1791 /* We have copied text into the gap, but we have not altered 1791 /* We have copied text into the gap, but we have not marked
1792 PT or PT_BYTE yet. So we can pass PT and PT_BYTE 1792 it as part of the buffer. So we can use the old FROM and FROM_BYTE
1793 to these functions and get the same results as we would 1793 here, for both the previous text and the following text.
1794 have got earlier on. Meanwhile, GPT_ADDR does point to 1794 Meanwhile, GPT_ADDR does point to
1795 the text that has been stored by copy_text. */ 1795 the text that has been stored by copy_text. */
1796 1796
1797 combined_before_bytes 1797 combined_before_bytes
1798 = count_combining_before (GPT_ADDR, outgoing_insbytes, PT, PT_BYTE); 1798 = count_combining_before (GPT_ADDR, outgoing_insbytes, from, from_byte);
1799 combined_after_bytes 1799 combined_after_bytes
1800 = count_combining_after (GPT_ADDR, outgoing_insbytes, PT, PT_BYTE); 1800 = count_combining_after (GPT_ADDR, outgoing_insbytes, from, from_byte);
1801 1801
1802 /* Record deletion of the surrounding text that combines with 1802 /* Record deletion of the surrounding text that combines with
1803 the insertion. This, together with recording the insertion, 1803 the insertion. This, together with recording the insertion,
1804 will add up to the right stuff in the undo list. 1804 will add up to the right stuff in the undo list.
1805 1805
1810 { 1810 {
1811 Lisp_Object deletion; 1811 Lisp_Object deletion;
1812 deletion = Qnil; 1812 deletion = Qnil;
1813 1813
1814 if (! EQ (current_buffer->undo_list, Qt)) 1814 if (! EQ (current_buffer->undo_list, Qt))
1815 deletion = make_buffer_string_both (PT, PT_BYTE, 1815 deletion = make_buffer_string_both (from, from_byte,
1816 PT + combined_after_bytes, 1816 from + combined_after_bytes,
1817 PT_BYTE + combined_after_bytes, 1); 1817 from_byte + combined_after_bytes, 1);
1818 1818
1819 adjust_markers_for_record_delete (PT, PT_BYTE, 1819 adjust_markers_for_record_delete (from, from_byte,
1820 PT + combined_after_bytes, 1820 from + combined_after_bytes,
1821 PT_BYTE + combined_after_bytes); 1821 from_byte + combined_after_bytes);
1822 if (! EQ (current_buffer->undo_list, Qt)) 1822 if (! EQ (current_buffer->undo_list, Qt))
1823 record_delete (PT, deletion); 1823 record_delete (from, deletion);
1824 } 1824 }
1825 1825
1826 if (combined_before_bytes) 1826 if (combined_before_bytes)
1827 { 1827 {
1828 Lisp_Object deletion; 1828 Lisp_Object deletion;
1829 deletion = Qnil; 1829 deletion = Qnil;
1830 1830
1831 if (! EQ (current_buffer->undo_list, Qt)) 1831 if (! EQ (current_buffer->undo_list, Qt))
1832 deletion = make_buffer_string_both (PT - 1, CHAR_TO_BYTE (PT - 1), 1832 deletion = make_buffer_string_both (from - 1, CHAR_TO_BYTE (from - 1),
1833 PT, PT_BYTE, 1); 1833 from, from_byte, 1);
1834 adjust_markers_for_record_delete (PT - 1, CHAR_TO_BYTE (PT - 1), 1834 adjust_markers_for_record_delete (from - 1, CHAR_TO_BYTE (from - 1),
1835 PT, PT_BYTE); 1835 from, from_byte);
1836 if (! EQ (current_buffer->undo_list, Qt)) 1836 if (! EQ (current_buffer->undo_list, Qt))
1837 record_delete (PT - 1, deletion); 1837 record_delete (from - 1, deletion);
1838 } 1838 }
1839 1839
1840 record_insert (PT - !!combined_before_bytes, 1840 record_insert (from - !!combined_before_bytes,
1841 inschars - combined_before_bytes + !!combined_before_bytes); 1841 inschars - combined_before_bytes + !!combined_before_bytes);
1842 1842
1843 GAP_SIZE -= outgoing_insbytes; 1843 GAP_SIZE -= outgoing_insbytes;
1844 GPT += inschars; 1844 GPT += inschars;
1845 ZV += inschars; 1845 ZV += inschars;
1864 adjust_markers_for_insert (from, from_byte, 1864 adjust_markers_for_insert (from, from_byte,
1865 from + inschars, from_byte + outgoing_insbytes, 1865 from + inschars, from_byte + outgoing_insbytes,
1866 combined_before_bytes, combined_after_bytes, 0); 1866 combined_before_bytes, combined_after_bytes, 0);
1867 1867
1868 #ifdef USE_TEXT_PROPERTIES 1868 #ifdef USE_TEXT_PROPERTIES
1869 offset_intervals (current_buffer, PT, inschars - nchars_del); 1869 offset_intervals (current_buffer, from, inschars - nchars_del);
1870 1870
1871 /* Get the intervals for the part of the string we are inserting-- 1871 /* Get the intervals for the part of the string we are inserting--
1872 not including the combined-before bytes. */ 1872 not including the combined-before bytes. */
1873 intervals = XSTRING (new)->intervals; 1873 intervals = XSTRING (new)->intervals;
1874 /* Insert those intervals. */ 1874 /* Insert those intervals. */
1897 CHECK_MARKERS (); 1897 CHECK_MARKERS ();
1898 1898
1899 MODIFF++; 1899 MODIFF++;
1900 UNGCPRO; 1900 UNGCPRO;
1901 1901
1902 signal_after_change (from, nchars_del, PT - from); 1902 signal_after_change (from, nchars_del, GPT - from);
1903 } 1903 }
1904 1904
1905 /* Delete characters in current buffer 1905 /* Delete characters in current buffer
1906 from FROM up to (but not including) TO. 1906 from FROM up to (but not including) TO.
1907 If TO comes before FROM, we delete nothing. */ 1907 If TO comes before FROM, we delete nothing. */