diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/coding.c | 43 | ||||
| -rw-r--r-- | src/insdel.c | 19 | ||||
| -rw-r--r-- | src/lisp.h | 4 |
4 files changed, 69 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ae25a3c5d00..2c77950c262 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2013-03-10 handa <handa@gnu.org> | ||
| 2 | |||
| 3 | * lisp.h (adjust_after_replace): Extern it. | ||
| 4 | |||
| 5 | * coding.c (detect_coding): Cound the heading ASCII bytes in the | ||
| 6 | case of detection for coding_category_utf_8_auto. | ||
| 7 | (decode_coding_gap) [not CODING_DISABLE_ASCII_OPTIMIZATION]: Skip | ||
| 8 | decoding if all bytes are ASCII. | ||
| 9 | |||
| 10 | * insdel.c (adjust_after_replace): Make it public. New arg | ||
| 11 | text_at_gap_tail. | ||
| 12 | (adjust_after_insert): Call adjust_after_replace with the new arg | ||
| 13 | value 0. | ||
| 14 | |||
| 1 | 2013-03-09 Stefan Monnier <monnier@iro.umontreal.ca> | 15 | 2013-03-09 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 16 | ||
| 3 | * keyboard.h (EVENT_START, EVENT_END, POSN_WINDOW, POSN_POSN) | 17 | * keyboard.h (EVENT_START, EVENT_END, POSN_WINDOW, POSN_POSN) |
diff --git a/src/coding.c b/src/coding.c index 32da72ab626..f33b5e7c7d5 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6349,7 +6349,12 @@ detect_coding (struct coding_system *coding) | |||
| 6349 | coding_systems | 6349 | coding_systems |
| 6350 | = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); | 6350 | = AREF (CODING_ID_ATTRS (coding->id), coding_attr_utf_bom); |
| 6351 | detect_info.found = detect_info.rejected = 0; | 6351 | detect_info.found = detect_info.rejected = 0; |
| 6352 | coding->head_ascii = 0; | 6352 | for (src = coding->source; src < src_end; src++) |
| 6353 | { | ||
| 6354 | if (*src & 0x80) | ||
| 6355 | break; | ||
| 6356 | } | ||
| 6357 | coding->head_ascii = src - coding->source; | ||
| 6353 | if (CONSP (coding_systems) | 6358 | if (CONSP (coding_systems) |
| 6354 | && detect_coding_utf_8 (coding, &detect_info)) | 6359 | && detect_coding_utf_8 (coding, &detect_info)) |
| 6355 | { | 6360 | { |
| @@ -7487,8 +7492,6 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7487 | ptrdiff_t count = SPECPDL_INDEX (); | 7492 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7488 | Lisp_Object attrs; | 7493 | Lisp_Object attrs; |
| 7489 | 7494 | ||
| 7490 | code_conversion_save (0, 0); | ||
| 7491 | |||
| 7492 | coding->src_object = Fcurrent_buffer (); | 7495 | coding->src_object = Fcurrent_buffer (); |
| 7493 | coding->src_chars = chars; | 7496 | coding->src_chars = chars; |
| 7494 | coding->src_bytes = bytes; | 7497 | coding->src_bytes = bytes; |
| @@ -7502,13 +7505,45 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7502 | 7505 | ||
| 7503 | if (CODING_REQUIRE_DETECTION (coding)) | 7506 | if (CODING_REQUIRE_DETECTION (coding)) |
| 7504 | detect_coding (coding); | 7507 | detect_coding (coding); |
| 7508 | attrs = CODING_ID_ATTRS (coding->id); | ||
| 7509 | #ifndef CODING_DISABLE_ASCII_OPTIMIZATION | ||
| 7510 | if (! NILP (CODING_ATTR_ASCII_COMPAT (attrs)) | ||
| 7511 | && NILP (CODING_ATTR_POST_READ (attrs)) | ||
| 7512 | && NILP (get_translation_table (attrs, 0, NULL))) | ||
| 7513 | { | ||
| 7514 | /* We can skip the conversion if all source bytes are ASCII. */ | ||
| 7515 | if (coding->head_ascii < 0) | ||
| 7516 | { | ||
| 7517 | /* We have not yet counted the number of ASCII bytes at the | ||
| 7518 | head of the source. Do it now. */ | ||
| 7519 | const unsigned char *src, *src_end; | ||
| 7520 | |||
| 7521 | coding_set_source (coding); | ||
| 7522 | src_end = coding->source + coding->src_bytes; | ||
| 7523 | for (src = coding->source; src < src_end; src++) | ||
| 7524 | { | ||
| 7525 | if (*src & 0x80) | ||
| 7526 | break; | ||
| 7527 | } | ||
| 7528 | coding->head_ascii = src - coding->source; | ||
| 7529 | } | ||
| 7530 | if (coding->src_bytes == coding->head_ascii) | ||
| 7531 | { | ||
| 7532 | /* No need of conversion. Use the data in the gap as is. */ | ||
| 7533 | coding->produced_char = chars; | ||
| 7534 | coding->produced = bytes; | ||
| 7535 | adjust_after_replace (PT, PT_BYTE, Qnil, chars, bytes, 1); | ||
| 7536 | return; | ||
| 7537 | } | ||
| 7538 | } | ||
| 7539 | #endif /* not CODING_DISABLE_ASCII_OPTIMIZATION */ | ||
| 7540 | code_conversion_save (0, 0); | ||
| 7505 | 7541 | ||
| 7506 | coding->mode |= CODING_MODE_LAST_BLOCK; | 7542 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 7507 | current_buffer->text->inhibit_shrinking = 1; | 7543 | current_buffer->text->inhibit_shrinking = 1; |
| 7508 | decode_coding (coding); | 7544 | decode_coding (coding); |
| 7509 | current_buffer->text->inhibit_shrinking = 0; | 7545 | current_buffer->text->inhibit_shrinking = 0; |
| 7510 | 7546 | ||
| 7511 | attrs = CODING_ID_ATTRS (coding->id); | ||
| 7512 | if (! NILP (CODING_ATTR_POST_READ (attrs))) | 7547 | if (! NILP (CODING_ATTR_POST_READ (attrs))) |
| 7513 | { | 7548 | { |
| 7514 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; | 7549 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
diff --git a/src/insdel.c b/src/insdel.c index fc5a4576dc2..992cebb04b0 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -1162,14 +1162,16 @@ insert_from_buffer_1 (struct buffer *buf, | |||
| 1162 | 1162 | ||
| 1163 | /* Record undo information and adjust markers and position keepers for | 1163 | /* Record undo information and adjust markers and position keepers for |
| 1164 | a replacement of a text PREV_TEXT at FROM to a new text of LEN | 1164 | a replacement of a text PREV_TEXT at FROM to a new text of LEN |
| 1165 | chars (LEN_BYTE bytes) which resides in the gap just after | 1165 | chars (LEN_BYTE bytes). If TEXT_AT_GAP_TAIL is zero, the new text |
| 1166 | GPT_ADDR. | 1166 | resides in the gap just after GPT_BYTE. Otherwise, the text |
| 1167 | resides at the gap tail; i.e. at (GAP_END_ADDR - LEN_BNYTE). | ||
| 1167 | 1168 | ||
| 1168 | PREV_TEXT nil means the new text was just inserted. */ | 1169 | PREV_TEXT nil means the new text was just inserted. */ |
| 1169 | 1170 | ||
| 1170 | static void | 1171 | void |
| 1171 | adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, | 1172 | adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, |
| 1172 | Lisp_Object prev_text, ptrdiff_t len, ptrdiff_t len_byte) | 1173 | Lisp_Object prev_text, ptrdiff_t len, ptrdiff_t len_byte, |
| 1174 | int text_at_gap_tail) | ||
| 1173 | { | 1175 | { |
| 1174 | ptrdiff_t nchars_del = 0, nbytes_del = 0; | 1176 | ptrdiff_t nchars_del = 0, nbytes_del = 0; |
| 1175 | 1177 | ||
| @@ -1189,8 +1191,11 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, | |||
| 1189 | GAP_SIZE -= len_byte; | 1191 | GAP_SIZE -= len_byte; |
| 1190 | ZV += len; Z+= len; | 1192 | ZV += len; Z+= len; |
| 1191 | ZV_BYTE += len_byte; Z_BYTE += len_byte; | 1193 | ZV_BYTE += len_byte; Z_BYTE += len_byte; |
| 1192 | GPT += len; GPT_BYTE += len_byte; | 1194 | if (! text_at_gap_tail) |
| 1193 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | 1195 | { |
| 1196 | GPT += len; GPT_BYTE += len_byte; | ||
| 1197 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 1198 | } | ||
| 1194 | 1199 | ||
| 1195 | if (nchars_del > 0) | 1200 | if (nchars_del > 0) |
| 1196 | adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, | 1201 | adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, |
| @@ -1245,7 +1250,7 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte, | |||
| 1245 | GPT -= len; GPT_BYTE -= len_byte; | 1250 | GPT -= len; GPT_BYTE -= len_byte; |
| 1246 | ZV -= len; ZV_BYTE -= len_byte; | 1251 | ZV -= len; ZV_BYTE -= len_byte; |
| 1247 | Z -= len; Z_BYTE -= len_byte; | 1252 | Z -= len; Z_BYTE -= len_byte; |
| 1248 | adjust_after_replace (from, from_byte, Qnil, newlen, len_byte); | 1253 | adjust_after_replace (from, from_byte, Qnil, newlen, len_byte, 0); |
| 1249 | } | 1254 | } |
| 1250 | 1255 | ||
| 1251 | /* Replace the text from character positions FROM to TO with NEW, | 1256 | /* Replace the text from character positions FROM to TO with NEW, |
diff --git a/src/lisp.h b/src/lisp.h index e4993866b1f..171292f942e 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2900,6 +2900,10 @@ extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, | |||
| 2900 | extern void modify_region_1 (ptrdiff_t, ptrdiff_t, bool); | 2900 | extern void modify_region_1 (ptrdiff_t, ptrdiff_t, bool); |
| 2901 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); | 2901 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 2902 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); | 2902 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); |
| 2903 | extern void adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte, | ||
| 2904 | Lisp_Object prev_text, | ||
| 2905 | ptrdiff_t len, ptrdiff_t len_byte, | ||
| 2906 | int text_at_gap_tail); | ||
| 2903 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 2907 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
| 2904 | ptrdiff_t, ptrdiff_t); | 2908 | ptrdiff_t, ptrdiff_t); |
| 2905 | extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, | 2909 | extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, |