aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1999-12-15 00:13:49 +0000
committerKenichi Handa1999-12-15 00:13:49 +0000
commit0ef71121ca05194c4313778840f6dd31b020a7ee (patch)
treef335651b6995802f5c560a17d084528b9ca85312 /src
parent012fd715d2a20095a693df3f8cb3fadb5e0ece16 (diff)
downloademacs-0ef71121ca05194c4313778840f6dd31b020a7ee.tar.gz
emacs-0ef71121ca05194c4313778840f6dd31b020a7ee.zip
(copy_text): Adjusted for the change of CHAR_STRING.
(insert_char): Likewise. (insert): Call update_compositions. (insert_and_inherit): Likewise. (insert_before_markers): Likewise. (insert_before_markers_and_inherit): Likewise. (insert_from_string): Likewise. (insert_from_string_before_markers): Likewise. (insert_from_buffer): Likewise. (replace_range): Likewise. (count_combining_composition): Deleted. (count_combining_before): Delete codes for a composite character. (count_combining_after): Likewise. (del_range_1): Call update_compositions. (del_range_byte): Likewise. (del_range_both): Likewise. (Fcombine_after_change_execute): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c66
1 files changed, 17 insertions, 49 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 60a9284ce45..051152949aa 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -715,17 +715,13 @@ copy_text (from_addr, to_addr, nbytes,
715 while (nbytes > 0) 715 while (nbytes > 0)
716 { 716 {
717 int c = *from_addr++; 717 int c = *from_addr++;
718 unsigned char workbuf[4], *str;
719 int len;
720 718
721 if (c < 0400 719 if (c < 0400
722 && (c >= 0240 720 && (c >= 0240
723 || (c >= 0200 && !NILP (Vnonascii_translation_table)))) 721 || (c >= 0200 && !NILP (Vnonascii_translation_table))))
724 { 722 {
725 c = unibyte_char_to_multibyte (c); 723 c = unibyte_char_to_multibyte (c);
726 len = CHAR_STRING (c, workbuf, str); 724 to_addr += CHAR_STRING (c, to_addr);
727 bcopy (str, to_addr, len);
728 to_addr += len;
729 nbytes--; 725 nbytes--;
730 } 726 }
731 else 727 else
@@ -782,6 +778,7 @@ insert (string, nbytes)
782 int opoint = PT; 778 int opoint = PT;
783 insert_1 (string, nbytes, 0, 1, 0); 779 insert_1 (string, nbytes, 0, 1, 0);
784 signal_after_change (opoint, 0, PT - opoint); 780 signal_after_change (opoint, 0, PT - opoint);
781 update_compositions (opoint, PT, CHECK_BORDER);
785 } 782 }
786} 783}
787 784
@@ -797,6 +794,7 @@ insert_and_inherit (string, nbytes)
797 int opoint = PT; 794 int opoint = PT;
798 insert_1 (string, nbytes, 1, 1, 0); 795 insert_1 (string, nbytes, 1, 1, 0);
799 signal_after_change (opoint, 0, PT - opoint); 796 signal_after_change (opoint, 0, PT - opoint);
797 update_compositions (opoint, PT, CHECK_BORDER);
800 } 798 }
801} 799}
802 800
@@ -806,16 +804,15 @@ void
806insert_char (c) 804insert_char (c)
807 int c; 805 int c;
808{ 806{
809 unsigned char workbuf[4], *str; 807 unsigned char str[MAX_MULTIBYTE_LENGTH];
810 int len; 808 int len;
811 809
812 if (! NILP (current_buffer->enable_multibyte_characters)) 810 if (! NILP (current_buffer->enable_multibyte_characters))
813 len = CHAR_STRING (c, workbuf, str); 811 len = CHAR_STRING (c, str);
814 else 812 else
815 { 813 {
816 len = 1; 814 len = 1;
817 workbuf[0] = c; 815 str[0] = c;
818 str = workbuf;
819 } 816 }
820 817
821 insert (str, len); 818 insert (str, len);
@@ -846,6 +843,7 @@ insert_before_markers (string, nbytes)
846 843
847 insert_1 (string, nbytes, 0, 1, 1); 844 insert_1 (string, nbytes, 0, 1, 1);
848 signal_after_change (opoint, 0, PT - opoint); 845 signal_after_change (opoint, 0, PT - opoint);
846 update_compositions (opoint, PT, CHECK_BORDER);
849 } 847 }
850} 848}
851 849
@@ -862,6 +860,7 @@ insert_before_markers_and_inherit (string, nbytes)
862 860
863 insert_1 (string, nbytes, 1, 1, 1); 861 insert_1 (string, nbytes, 1, 1, 1);
864 signal_after_change (opoint, 0, PT - opoint); 862 signal_after_change (opoint, 0, PT - opoint);
863 update_compositions (opoint, PT, CHECK_BORDER);
865 } 864 }
866} 865}
867 866
@@ -877,33 +876,6 @@ insert_1 (string, nbytes, inherit, prepare, before_markers)
877 inherit, prepare, before_markers); 876 inherit, prepare, before_markers);
878} 877}
879 878
880/* See if the byte sequence at STR1 of length LEN1 combine with the
881 byte sequence at STR2 of length LEN2 to form a single composite
882 character. If so, return the number of bytes at the start of STR2
883 which combine in this way. Otherwise, return 0. If STR3 is not
884 NULL, it is a byte sequence of length LEN3 to be appended to STR1
885 before checking the combining. */
886int
887count_combining_composition (str1, len1, str2, len2, str3, len3)
888 unsigned char *str1, *str2, *str3;
889 int len1, len2, len3;
890{
891 int len = len1 + len2 + len3;
892 unsigned char *buf = (unsigned char *) alloca (len + 1);
893 int bytes;
894
895 bcopy (str1, buf, len1);
896 if (str3)
897 {
898 bcopy (str3, buf + len1, len3);
899 len1 += len3;
900 }
901 bcopy (str2, buf + len1 , len2);
902 buf[len] = 0;
903 PARSE_MULTIBYTE_SEQ (buf, len, bytes);
904 return (bytes <= len1 ? 0 : bytes - len1);
905}
906
907/* See if the bytes before POS/POS_BYTE combine with bytes 879/* See if the bytes before POS/POS_BYTE combine with bytes
908 at the start of STRING to form a single character. 880 at the start of STRING to form a single character.
909 If so, return the number of bytes at the start of STRING 881 If so, return the number of bytes at the start of STRING
@@ -935,10 +907,6 @@ count_combining_before (string, length, pos, pos_byte)
935 if (! BASE_LEADING_CODE_P (*p)) /* case (3) */ 907 if (! BASE_LEADING_CODE_P (*p)) /* case (3) */
936 return 0; 908 return 0;
937 909
938 /* A sequence of a composite character requires a special handling. */
939 if (*p == LEADING_CODE_COMPOSITION)
940 return count_combining_composition (p, len, string, length, NULL, 0);
941
942 combining_bytes = BYTES_BY_CHAR_HEAD (*p) - len; 910 combining_bytes = BYTES_BY_CHAR_HEAD (*p) - len;
943 if (combining_bytes <= 0) 911 if (combining_bytes <= 0)
944 /* The character preceding POS is, complete and no room for 912 /* The character preceding POS is, complete and no room for
@@ -1003,11 +971,7 @@ count_combining_after (string, length, pos, pos_byte)
1003 i--; 971 i--;
1004 if (i < 0 || !BASE_LEADING_CODE_P (p[i])) 972 if (i < 0 || !BASE_LEADING_CODE_P (p[i]))
1005 return 0; 973 return 0;
1006 /* A sequence of a composite character requires a special handling. */ 974
1007 if (p[i] == LEADING_CODE_COMPOSITION)
1008 return count_combining_composition (p + i, pos_byte - 1 - i,
1009 bufp, Z_BYTE - pos_byte,
1010 string, length);
1011 bytes = BYTES_BY_CHAR_HEAD (p[i]); 975 bytes = BYTES_BY_CHAR_HEAD (p[i]);
1012 return (bytes <= pos_byte - 1 - i + length 976 return (bytes <= pos_byte - 1 - i + length
1013 ? 0 977 ? 0
@@ -1015,10 +979,6 @@ count_combining_after (string, length, pos, pos_byte)
1015 } 979 }
1016 if (!BASE_LEADING_CODE_P (string[i])) 980 if (!BASE_LEADING_CODE_P (string[i]))
1017 return 0; 981 return 0;
1018 /* A sequence of a composite character requires a special handling. */
1019 if (string[i] == LEADING_CODE_COMPOSITION)
1020 return count_combining_composition (string + i, length - i,
1021 bufp, Z_BYTE - pos_byte, NULL, 0);
1022 982
1023 bytes = BYTES_BY_CHAR_HEAD (string[i]) - (length - i); 983 bytes = BYTES_BY_CHAR_HEAD (string[i]) - (length - i);
1024 bufp++, pos_byte++; 984 bufp++, pos_byte++;
@@ -1227,6 +1187,7 @@ insert_from_string (string, pos, pos_byte, length, length_byte, inherit)
1227 insert_from_string_1 (string, pos, pos_byte, length, length_byte, 1187 insert_from_string_1 (string, pos, pos_byte, length, length_byte,
1228 inherit, 0); 1188 inherit, 0);
1229 signal_after_change (opoint, 0, PT - opoint); 1189 signal_after_change (opoint, 0, PT - opoint);
1190 update_compositions (opoint, PT, CHECK_BORDER);
1230} 1191}
1231 1192
1232/* Like `insert_from_string' except that all markers pointing 1193/* Like `insert_from_string' except that all markers pointing
@@ -1243,6 +1204,7 @@ insert_from_string_before_markers (string, pos, pos_byte,
1243 insert_from_string_1 (string, pos, pos_byte, length, length_byte, 1204 insert_from_string_1 (string, pos, pos_byte, length, length_byte,
1244 inherit, 1); 1205 inherit, 1);
1245 signal_after_change (opoint, 0, PT - opoint); 1206 signal_after_change (opoint, 0, PT - opoint);
1207 update_compositions (opoint, PT, CHECK_BORDER);
1246} 1208}
1247 1209
1248/* Subroutine of the insertion functions above. */ 1210/* Subroutine of the insertion functions above. */
@@ -1412,6 +1374,7 @@ insert_from_buffer (buf, charpos, nchars, inherit)
1412 1374
1413 insert_from_buffer_1 (buf, charpos, nchars, inherit); 1375 insert_from_buffer_1 (buf, charpos, nchars, inherit);
1414 signal_after_change (opoint, 0, PT - opoint); 1376 signal_after_change (opoint, 0, PT - opoint);
1377 update_compositions (opoint, PT, CHECK_BORDER);
1415} 1378}
1416 1379
1417static void 1380static void
@@ -2043,6 +2006,7 @@ replace_range (from, to, new, prepare, inherit, markers)
2043 UNGCPRO; 2006 UNGCPRO;
2044 2007
2045 signal_after_change (from, nchars_del, GPT - from); 2008 signal_after_change (from, nchars_del, GPT - from);
2009 update_compositions (from, GPT, CHECK_BORDER);
2046} 2010}
2047 2011
2048/* Delete characters in current buffer 2012/* Delete characters in current buffer
@@ -2128,6 +2092,7 @@ del_range_byte (from_byte, to_byte, prepare)
2128 2092
2129 del_range_2 (from, from_byte, to, to_byte, 0); 2093 del_range_2 (from, from_byte, to, to_byte, 0);
2130 signal_after_change (from, to - from, 0); 2094 signal_after_change (from, to - from, 0);
2095 update_compositions (from, from, CHECK_HEAD);
2131} 2096}
2132 2097
2133/* Like del_range_1, but positions are specified both as charpos 2098/* Like del_range_1, but positions are specified both as charpos
@@ -2166,6 +2131,8 @@ del_range_both (from, from_byte, to, to_byte, prepare)
2166 2131
2167 del_range_2 (from, from_byte, to, to_byte, 0); 2132 del_range_2 (from, from_byte, to, to_byte, 0);
2168 signal_after_change (from, to - from, 0); 2133 signal_after_change (from, to - from, 0);
2134 update_compositions (from, from, CHECK_HEAD);
2135 update_compositions (from, from, CHECK_HEAD);
2169} 2136}
2170 2137
2171/* Delete a range of text, specified both as character positions 2138/* Delete a range of text, specified both as character positions
@@ -2692,6 +2659,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
2692 record_unwind_protect (Fcombine_after_change_execute_1, 2659 record_unwind_protect (Fcombine_after_change_execute_1,
2693 Vcombine_after_change_calls); 2660 Vcombine_after_change_calls);
2694 signal_after_change (begpos, endpos - begpos - change, endpos - begpos); 2661 signal_after_change (begpos, endpos - begpos - change, endpos - begpos);
2662 update_compositions (begpos, endpos, CHECK_ALL);
2695 2663
2696 return unbind_to (count, Qnil); 2664 return unbind_to (count, Qnil);
2697} 2665}