373 |
if (! m->insertion_type) |
if (! m->insertion_type) |
374 |
/* Normal markers will end up at the beginning of the |
/* Normal markers will end up at the beginning of the |
375 |
re-inserted text after undoing a deletion, and must be |
re-inserted text after undoing a deletion, and must be |
376 |
adjusted to move them to the correct place. */ |
adjusted to move them to the correct place. */ |
377 |
record_marker_adjustment (marker, from - charpos); |
record_marker_adjustment (marker, from - charpos); |
378 |
else if (charpos < to) |
else if (charpos < to) |
379 |
/* Before-insertion markers will automatically move forward |
/* Before-insertion markers will automatically move forward |
536 |
That won't work because so many places use `int'. |
That won't work because so many places use `int'. |
537 |
|
|
538 |
Make sure we don't introduce overflows in the calculation. */ |
Make sure we don't introduce overflows in the calculation. */ |
539 |
|
|
540 |
if (Z_BYTE - BEG_BYTE + GAP_SIZE |
if (Z_BYTE - BEG_BYTE + GAP_SIZE |
541 |
>= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1 |
>= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1 |
542 |
- nbytes_added)) |
- nbytes_added)) |
573 |
} |
} |
574 |
|
|
575 |
|
|
576 |
/* Make the gap NBYTES_REMOVED bytes shorted. */ |
/* Make the gap NBYTES_REMOVED bytes shorter. */ |
577 |
|
|
578 |
void |
void |
579 |
make_gap_smaller (nbytes_removed) |
make_gap_smaller (nbytes_removed) |
654 |
int |
int |
655 |
copy_text (from_addr, to_addr, nbytes, |
copy_text (from_addr, to_addr, nbytes, |
656 |
from_multibyte, to_multibyte) |
from_multibyte, to_multibyte) |
657 |
unsigned char *from_addr; |
const unsigned char *from_addr; |
658 |
unsigned char *to_addr; |
unsigned char *to_addr; |
659 |
int nbytes; |
int nbytes; |
660 |
int from_multibyte, to_multibyte; |
int from_multibyte, to_multibyte; |
723 |
|
|
724 |
int |
int |
725 |
count_size_as_multibyte (ptr, nbytes) |
count_size_as_multibyte (ptr, nbytes) |
726 |
unsigned char *ptr; |
const unsigned char *ptr; |
727 |
int nbytes; |
int nbytes; |
728 |
{ |
{ |
729 |
int i; |
int i; |
755 |
|
|
756 |
void |
void |
757 |
insert (string, nbytes) |
insert (string, nbytes) |
758 |
register unsigned char *string; |
register const unsigned char *string; |
759 |
register int nbytes; |
register int nbytes; |
760 |
{ |
{ |
761 |
if (nbytes > 0) |
if (nbytes > 0) |
771 |
|
|
772 |
void |
void |
773 |
insert_and_inherit (string, nbytes) |
insert_and_inherit (string, nbytes) |
774 |
register unsigned char *string; |
register const unsigned char *string; |
775 |
register int nbytes; |
register int nbytes; |
776 |
{ |
{ |
777 |
if (nbytes > 0) |
if (nbytes > 0) |
807 |
|
|
808 |
void |
void |
809 |
insert_string (s) |
insert_string (s) |
810 |
char *s; |
const char *s; |
811 |
{ |
{ |
812 |
insert (s, strlen (s)); |
insert (s, strlen (s)); |
813 |
} |
} |
819 |
|
|
820 |
void |
void |
821 |
insert_before_markers (string, nbytes) |
insert_before_markers (string, nbytes) |
822 |
unsigned char *string; |
const unsigned char *string; |
823 |
register int nbytes; |
register int nbytes; |
824 |
{ |
{ |
825 |
if (nbytes > 0) |
if (nbytes > 0) |
836 |
|
|
837 |
void |
void |
838 |
insert_before_markers_and_inherit (string, nbytes) |
insert_before_markers_and_inherit (string, nbytes) |
839 |
unsigned char *string; |
const unsigned char *string; |
840 |
register int nbytes; |
register int nbytes; |
841 |
{ |
{ |
842 |
if (nbytes > 0) |
if (nbytes > 0) |
853 |
|
|
854 |
void |
void |
855 |
insert_1 (string, nbytes, inherit, prepare, before_markers) |
insert_1 (string, nbytes, inherit, prepare, before_markers) |
856 |
register unsigned char *string; |
register const unsigned char *string; |
857 |
register int nbytes; |
register int nbytes; |
858 |
int inherit, prepare, before_markers; |
int inherit, prepare, before_markers; |
859 |
{ |
{ |
871 |
|
|
872 |
int |
int |
873 |
count_combining_before (string, length, pos, pos_byte) |
count_combining_before (string, length, pos, pos_byte) |
874 |
unsigned char *string; |
const unsigned char *string; |
875 |
int length; |
int length; |
876 |
int pos, pos_byte; |
int pos, pos_byte; |
877 |
{ |
{ |
878 |
int len, combining_bytes; |
int len, combining_bytes; |
879 |
unsigned char *p; |
const unsigned char *p; |
880 |
|
|
881 |
if (NILP (current_buffer->enable_multibyte_characters)) |
if (NILP (current_buffer->enable_multibyte_characters)) |
882 |
return 0; |
return 0; |
918 |
|
|
919 |
int |
int |
920 |
count_combining_after (string, length, pos, pos_byte) |
count_combining_after (string, length, pos, pos_byte) |
921 |
unsigned char *string; |
const unsigned char *string; |
922 |
int length; |
int length; |
923 |
int pos, pos_byte; |
int pos, pos_byte; |
924 |
{ |
{ |
984 |
|
|
985 |
void |
void |
986 |
insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) |
insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers) |
987 |
register unsigned char *string; |
register const unsigned char *string; |
988 |
register int nchars, nbytes; |
register int nchars, nbytes; |
989 |
int inherit, prepare, before_markers; |
int inherit, prepare, before_markers; |
990 |
{ |
{ |
991 |
if (nchars == 0) |
if (nchars == 0) |
992 |
return; |
return; |
993 |
|
|
994 |
if (NILP (current_buffer->enable_multibyte_characters)) |
if (NILP (current_buffer->enable_multibyte_characters)) |
995 |
nchars = nbytes; |
nchars = nbytes; |
996 |
|
|
1031 |
if (GPT_BYTE < GPT) |
if (GPT_BYTE < GPT) |
1032 |
abort (); |
abort (); |
1033 |
|
|
1034 |
|
/* The insert may have been in the unchanged region, so check again. */ |
1035 |
|
if (Z - GPT < END_UNCHANGED) |
1036 |
|
END_UNCHANGED = Z - GPT; |
1037 |
|
|
1038 |
adjust_overlays_for_insert (PT, nchars); |
adjust_overlays_for_insert (PT, nchars); |
1039 |
adjust_markers_for_insert (PT, PT_BYTE, |
adjust_markers_for_insert (PT, PT_BYTE, |
1040 |
PT + nchars, PT_BYTE + nbytes, |
PT + nchars, PT_BYTE + nbytes, |
1111 |
outgoing_nbytes = nchars; |
outgoing_nbytes = nchars; |
1112 |
else if (! STRING_MULTIBYTE (string)) |
else if (! STRING_MULTIBYTE (string)) |
1113 |
outgoing_nbytes |
outgoing_nbytes |
1114 |
= count_size_as_multibyte (&XSTRING (string)->data[pos_byte], |
= count_size_as_multibyte (SDATA (string) + pos_byte, |
1115 |
nbytes); |
nbytes); |
1116 |
|
|
1117 |
GCPRO1 (string); |
GCPRO1 (string); |
1128 |
|
|
1129 |
/* Copy the string text into the buffer, perhaps converting |
/* Copy the string text into the buffer, perhaps converting |
1130 |
between single-byte and multibyte. */ |
between single-byte and multibyte. */ |
1131 |
copy_text (XSTRING (string)->data + pos_byte, GPT_ADDR, nbytes, |
copy_text (SDATA (string) + pos_byte, GPT_ADDR, nbytes, |
1132 |
STRING_MULTIBYTE (string), |
STRING_MULTIBYTE (string), |
1133 |
! NILP (current_buffer->enable_multibyte_characters)); |
! NILP (current_buffer->enable_multibyte_characters)); |
1134 |
|
|
1158 |
if (GPT_BYTE < GPT) |
if (GPT_BYTE < GPT) |
1159 |
abort (); |
abort (); |
1160 |
|
|
1161 |
|
/* The insert may have been in the unchanged region, so check again. */ |
1162 |
|
if (Z - GPT < END_UNCHANGED) |
1163 |
|
END_UNCHANGED = Z - GPT; |
1164 |
|
|
1165 |
adjust_overlays_for_insert (PT, nchars); |
adjust_overlays_for_insert (PT, nchars); |
1166 |
adjust_markers_for_insert (PT, PT_BYTE, PT + nchars, |
adjust_markers_for_insert (PT, PT_BYTE, PT + nchars, |
1167 |
PT_BYTE + outgoing_nbytes, |
PT_BYTE + outgoing_nbytes, |
1169 |
|
|
1170 |
offset_intervals (current_buffer, PT, nchars); |
offset_intervals (current_buffer, PT, nchars); |
1171 |
|
|
1172 |
intervals = XSTRING (string)->intervals; |
intervals = STRING_INTERVALS (string); |
1173 |
/* Get the intervals for the part of the string we are inserting. */ |
/* Get the intervals for the part of the string we are inserting. */ |
1174 |
if (nbytes < STRING_BYTES (XSTRING (string))) |
if (nbytes < SBYTES (string)) |
1175 |
intervals = copy_intervals (intervals, pos, nchars); |
intervals = copy_intervals (intervals, pos, nchars); |
1176 |
|
|
1177 |
/* Insert those intervals. */ |
/* Insert those intervals. */ |
1178 |
graft_intervals_into_buffer (intervals, PT, nchars, |
graft_intervals_into_buffer (intervals, PT, nchars, |
1179 |
current_buffer, inherit); |
current_buffer, inherit); |
1239 |
|
|
1240 |
if (chunk < incoming_nbytes) |
if (chunk < incoming_nbytes) |
1241 |
outgoing_after_gap |
outgoing_after_gap |
1242 |
= count_size_as_multibyte (BUF_BYTE_ADDRESS (buf, |
= count_size_as_multibyte (BUF_BYTE_ADDRESS (buf, |
1243 |
from_byte + chunk), |
from_byte + chunk), |
1244 |
incoming_nbytes - chunk); |
incoming_nbytes - chunk); |
1245 |
|
|
1246 |
outgoing_nbytes = outgoing_before_gap + outgoing_after_gap; |
outgoing_nbytes = outgoing_before_gap + outgoing_after_gap; |
1247 |
} |
} |
1248 |
|
|
1249 |
/* Make sure point-max won't overflow after this insertion. */ |
/* Make sure point-max won't overflow after this insertion. */ |
1250 |
XSETINT (temp, outgoing_nbytes + Z); |
XSETINT (temp, outgoing_nbytes + Z); |
1251 |
if (outgoing_nbytes + Z != XINT (temp)) |
if (outgoing_nbytes + Z != XINT (temp)) |
1309 |
if (GPT_BYTE < GPT) |
if (GPT_BYTE < GPT) |
1310 |
abort (); |
abort (); |
1311 |
|
|
1312 |
|
/* The insert may have been in the unchanged region, so check again. */ |
1313 |
|
if (Z - GPT < END_UNCHANGED) |
1314 |
|
END_UNCHANGED = Z - GPT; |
1315 |
|
|
1316 |
adjust_overlays_for_insert (PT, nchars); |
adjust_overlays_for_insert (PT, nchars); |
1317 |
adjust_markers_for_insert (PT, PT_BYTE, PT + nchars, |
adjust_markers_for_insert (PT, PT_BYTE, PT + nchars, |
1318 |
PT_BYTE + outgoing_nbytes, |
PT_BYTE + outgoing_nbytes, |
1329 |
from += nchars; |
from += nchars; |
1330 |
intervals = copy_intervals (intervals, from, nchars); |
intervals = copy_intervals (intervals, from, nchars); |
1331 |
} |
} |
1332 |
|
|
1333 |
/* Insert those intervals. */ |
/* Insert those intervals. */ |
1334 |
graft_intervals_into_buffer (intervals, PT, nchars, current_buffer, inherit); |
graft_intervals_into_buffer (intervals, PT, nchars, current_buffer, inherit); |
1335 |
|
|
1358 |
|
|
1359 |
if (STRINGP (prev_text)) |
if (STRINGP (prev_text)) |
1360 |
{ |
{ |
1361 |
nchars_del = XSTRING (prev_text)->size; |
nchars_del = SCHARS (prev_text); |
1362 |
nbytes_del = STRING_BYTES (XSTRING (prev_text)); |
nbytes_del = SBYTES (prev_text); |
1363 |
} |
} |
1364 |
|
|
1365 |
/* Update various buffer positions for the new text. */ |
/* Update various buffer positions for the new text. */ |
1493 |
Lisp_Object new; |
Lisp_Object new; |
1494 |
int from, to, prepare, inherit, markers; |
int from, to, prepare, inherit, markers; |
1495 |
{ |
{ |
1496 |
int inschars = XSTRING (new)->size; |
int inschars = SCHARS (new); |
1497 |
int insbytes = STRING_BYTES (XSTRING (new)); |
int insbytes = SBYTES (new); |
1498 |
int from_byte, to_byte; |
int from_byte, to_byte; |
1499 |
int nbytes_del, nchars_del; |
int nbytes_del, nchars_del; |
1500 |
register Lisp_Object temp; |
register Lisp_Object temp; |
1539 |
outgoing_insbytes = inschars; |
outgoing_insbytes = inschars; |
1540 |
else if (! STRING_MULTIBYTE (new)) |
else if (! STRING_MULTIBYTE (new)) |
1541 |
outgoing_insbytes |
outgoing_insbytes |
1542 |
= count_size_as_multibyte (XSTRING (new)->data, insbytes); |
= count_size_as_multibyte (SDATA (new), insbytes); |
1543 |
|
|
1544 |
/* Make sure point-max won't overflow after this insertion. */ |
/* Make sure point-max won't overflow after this insertion. */ |
1545 |
XSETINT (temp, Z_BYTE - nbytes_del + insbytes); |
XSETINT (temp, Z_BYTE - nbytes_del + insbytes); |
1582 |
|
|
1583 |
/* Copy the string text into the buffer, perhaps converting |
/* Copy the string text into the buffer, perhaps converting |
1584 |
between single-byte and multibyte. */ |
between single-byte and multibyte. */ |
1585 |
copy_text (XSTRING (new)->data, GPT_ADDR, insbytes, |
copy_text (SDATA (new), GPT_ADDR, insbytes, |
1586 |
STRING_MULTIBYTE (new), |
STRING_MULTIBYTE (new), |
1587 |
! NILP (current_buffer->enable_multibyte_characters)); |
! NILP (current_buffer->enable_multibyte_characters)); |
1588 |
|
|
1629 |
|
|
1630 |
/* Get the intervals for the part of the string we are inserting-- |
/* Get the intervals for the part of the string we are inserting-- |
1631 |
not including the combined-before bytes. */ |
not including the combined-before bytes. */ |
1632 |
intervals = XSTRING (new)->intervals; |
intervals = STRING_INTERVALS (new); |
1633 |
/* Insert those intervals. */ |
/* Insert those intervals. */ |
1634 |
graft_intervals_into_buffer (intervals, from, inschars, |
graft_intervals_into_buffer (intervals, from, inschars, |
1635 |
current_buffer, inherit); |
current_buffer, inherit); |
2129 |
return; |
return; |
2130 |
} |
} |
2131 |
|
|
2132 |
if (!NILP (combine_after_change_list)) |
if (!NILP (combine_after_change_list)) |
2133 |
Fcombine_after_change_execute (); |
Fcombine_after_change_execute (); |
2134 |
|
|
2135 |
if (!NILP (Vafter_change_functions)) |
if (!NILP (Vafter_change_functions)) |
2205 |
doc: /* This function is for use internally in `combine-after-change-calls'. */) |
doc: /* This function is for use internally in `combine-after-change-calls'. */) |
2206 |
() |
() |
2207 |
{ |
{ |
2208 |
int count = specpdl_ptr - specpdl; |
int count = SPECPDL_INDEX (); |
2209 |
int beg, end, change; |
int beg, end, change; |
2210 |
int begpos, endpos; |
int begpos, endpos; |
2211 |
Lisp_Object tail; |
Lisp_Object tail; |
2260 |
that was changed. */ |
that was changed. */ |
2261 |
begpos = BEG + beg; |
begpos = BEG + beg; |
2262 |
endpos = Z - end; |
endpos = Z - end; |
2263 |
|
|
2264 |
/* We are about to handle these, so discard them. */ |
/* We are about to handle these, so discard them. */ |
2265 |
combine_after_change_list = Qnil; |
combine_after_change_list = Qnil; |
2266 |
|
|