Mercurial > emacs
comparison src/coding.c @ 23514:7bad909cd6f1
(setup_coding_system): Fix setting up
coding->spec.ccl.valid_codes for CCL based coding system.
(code_convert_region): Set point to FROM before inserting the
result of pre-write-funciton. Preserve original point.
(code_convert_string): If coding->type is coding_type_ccl, do
conversion even if the length of conversion region is zero.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 21 Oct 1998 11:50:56 +0000 |
parents | 6f03301d36a7 |
children | 28cd5faf93dd |
comparison
equal
deleted
inserted
replaced
23513:0a3fa36b323b | 23514:7bad909cd6f1 |
---|---|
3136 { | 3136 { |
3137 int start = XINT (XCONS (this)->car); | 3137 int start = XINT (XCONS (this)->car); |
3138 int end = XINT (XCONS (this)->cdr); | 3138 int end = XINT (XCONS (this)->cdr); |
3139 | 3139 |
3140 if (start >= 0 && start <= end && end < 256) | 3140 if (start >= 0 && start <= end && end < 256) |
3141 while (start < end) | 3141 while (start <= end) |
3142 coding->spec.ccl.valid_codes[start++] = 1; | 3142 coding->spec.ccl.valid_codes[start++] = 1; |
3143 } | 3143 } |
3144 } | 3144 } |
3145 } | 3145 } |
3146 } | 3146 } |
4167 int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 4167 int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
4168 int first = 1; | 4168 int first = 1; |
4169 int fake_multibyte = 0; | 4169 int fake_multibyte = 0; |
4170 unsigned char *src, *dst; | 4170 unsigned char *src, *dst; |
4171 Lisp_Object deletion; | 4171 Lisp_Object deletion; |
4172 int orig_point = PT, orig_len = len; | |
4172 | 4173 |
4173 deletion = Qnil; | 4174 deletion = Qnil; |
4174 saved_coding_symbol = Qnil; | 4175 saved_coding_symbol = Qnil; |
4175 | 4176 |
4176 if (from < PT && PT < to) | 4177 if (from < PT && PT < to) |
4177 SET_PT_BOTH (from, from_byte); | 4178 { |
4179 TEMP_SET_PT_BOTH (from, from_byte); | |
4180 orig_point = from; | |
4181 } | |
4178 | 4182 |
4179 if (replace) | 4183 if (replace) |
4180 { | 4184 { |
4181 int saved_from = from; | 4185 int saved_from = from; |
4182 | 4186 |
4267 { | 4271 { |
4268 len = ZV - BEGV; | 4272 len = ZV - BEGV; |
4269 new = current_buffer; | 4273 new = current_buffer; |
4270 set_buffer_internal_1 (prev); | 4274 set_buffer_internal_1 (prev); |
4271 del_range_2 (from, from_byte, to, to_byte); | 4275 del_range_2 (from, from_byte, to, to_byte); |
4272 insert_from_buffer (new, BEG, len, 0); | 4276 TEMP_SET_PT_BOTH (from, from_byte); |
4277 insert_from_buffer (new, 1, len, 0); | |
4278 if (orig_point >= to) | |
4279 orig_point += len - orig_len; | |
4280 else if (orig_point > from) | |
4281 orig_point = from; | |
4282 orig_len = len; | |
4273 to = from + len; | 4283 to = from + len; |
4284 from_byte = multibyte ? CHAR_TO_BYTE (from) : from_byte; | |
4274 to_byte = multibyte ? CHAR_TO_BYTE (to) : to; | 4285 to_byte = multibyte ? CHAR_TO_BYTE (to) : to; |
4275 len_byte = to_byte - from_byte; | 4286 len_byte = to_byte - from_byte; |
4287 TEMP_SET_PT_BOTH (from, from_byte); | |
4276 } | 4288 } |
4277 } | 4289 } |
4278 | 4290 |
4279 if (replace) | 4291 if (replace) |
4280 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); | 4292 deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1); |
4514 adjust_after_replace (from, from_byte, deletion, inserted, inserted_byte); | 4526 adjust_after_replace (from, from_byte, deletion, inserted, inserted_byte); |
4515 | 4527 |
4516 if (! encodep && ! NILP (coding->post_read_conversion)) | 4528 if (! encodep && ! NILP (coding->post_read_conversion)) |
4517 { | 4529 { |
4518 Lisp_Object val; | 4530 Lisp_Object val; |
4519 int orig_inserted = inserted, pos = PT; | 4531 |
4520 | 4532 if (from != PT) |
4521 if (from != pos) | 4533 TEMP_SET_PT_BOTH (from, from_byte); |
4522 temp_set_point_both (current_buffer, from, from_byte); | |
4523 val = call1 (coding->post_read_conversion, make_number (inserted)); | 4534 val = call1 (coding->post_read_conversion, make_number (inserted)); |
4524 if (! NILP (val)) | 4535 if (! NILP (val)) |
4525 { | 4536 { |
4526 CHECK_NUMBER (val, 0); | 4537 CHECK_NUMBER (val, 0); |
4527 inserted = XFASTINT (val); | 4538 inserted = XFASTINT (val); |
4528 } | 4539 } |
4529 if (pos >= from + orig_inserted) | 4540 } |
4530 temp_set_point (current_buffer, pos + (inserted - orig_inserted)); | 4541 |
4542 if (orig_point >= from) | |
4543 { | |
4544 if (orig_point >= from + orig_len) | |
4545 orig_point += inserted - orig_len; | |
4546 else | |
4547 orig_point = from; | |
4548 TEMP_SET_PT (orig_point); | |
4531 } | 4549 } |
4532 | 4550 |
4533 signal_after_change (from, to - from, inserted); | 4551 signal_after_change (from, to - from, inserted); |
4534 | 4552 |
4535 { | 4553 { |
4563 /* Since we have to call Lisp functions which assume target text | 4581 /* Since we have to call Lisp functions which assume target text |
4564 is in a buffer, after setting a temporary buffer, call | 4582 is in a buffer, after setting a temporary buffer, call |
4565 code_convert_region. */ | 4583 code_convert_region. */ |
4566 int count = specpdl_ptr - specpdl; | 4584 int count = specpdl_ptr - specpdl; |
4567 struct buffer *prev = current_buffer; | 4585 struct buffer *prev = current_buffer; |
4568 | 4586 |
4569 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 4587 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
4570 temp_output_buffer_setup (" *code-converting-work*"); | 4588 temp_output_buffer_setup (" *code-converting-work*"); |
4571 set_buffer_internal (XBUFFER (Vstandard_output)); | 4589 set_buffer_internal (XBUFFER (Vstandard_output)); |
4572 if (encodep) | 4590 if (encodep) |
4573 insert_from_string (str, 0, 0, to, to_byte, 0); | 4591 insert_from_string (str, 0, 0, to, to_byte, 0); |
4617 { | 4635 { |
4618 /* Try to skip the heading and tailing ASCIIs. */ | 4636 /* Try to skip the heading and tailing ASCIIs. */ |
4619 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 4637 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
4620 encodep); | 4638 encodep); |
4621 } | 4639 } |
4622 if (from == to_byte) | 4640 if (from == to_byte |
4641 && coding->type != coding_type_ccl) | |
4623 return (nocopy ? str : Fcopy_sequence (str)); | 4642 return (nocopy ? str : Fcopy_sequence (str)); |
4624 | 4643 |
4625 if (encodep) | 4644 if (encodep) |
4626 len = encoding_buffer_size (coding, to_byte - from); | 4645 len = encoding_buffer_size (coding, to_byte - from); |
4627 else | 4646 else |