Mercurial > emacs
comparison src/fileio.c @ 89478:756c32423971
(choose_write_coding_system): Return a decided coding system.
(Fwrite_region): Set Vlast_coding_system_used to the return value
of choose_write_coding_system.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 26 Jun 2003 00:26:38 +0000 |
parents | 0312225e013a |
children | 2f877ed80fa6 |
comparison
equal
deleted
inserted
replaced
89477:3fbea8672973 | 89478:756c32423971 |
---|---|
4581 return Qnil; | 4581 return Qnil; |
4582 } | 4582 } |
4583 | 4583 |
4584 /* Decide the coding-system to encode the data with. */ | 4584 /* Decide the coding-system to encode the data with. */ |
4585 | 4585 |
4586 void | 4586 static Lisp_Object |
4587 choose_write_coding_system (start, end, filename, | 4587 choose_write_coding_system (start, end, filename, |
4588 append, visit, lockname, coding) | 4588 append, visit, lockname, coding) |
4589 Lisp_Object start, end, filename, append, visit, lockname; | 4589 Lisp_Object start, end, filename, append, visit, lockname; |
4590 struct coding_system *coding; | 4590 struct coding_system *coding; |
4591 { | 4591 { |
4629 coding_systems = Ffind_operation_coding_system (7, args); | 4629 coding_systems = Ffind_operation_coding_system (7, args); |
4630 if (CONSP (coding_systems) && !NILP (XCDR (coding_systems))) | 4630 if (CONSP (coding_systems) && !NILP (XCDR (coding_systems))) |
4631 val = XCDR (coding_systems); | 4631 val = XCDR (coding_systems); |
4632 } | 4632 } |
4633 | 4633 |
4634 if (NILP (val) | 4634 if (NILP (val)) |
4635 && !NILP (current_buffer->buffer_file_coding_system)) | |
4636 { | 4635 { |
4637 /* If we still have not decided a coding system, use the | 4636 /* If we still have not decided a coding system, use the |
4638 default value of buffer-file-coding-system. */ | 4637 default value of buffer-file-coding-system. */ |
4639 val = current_buffer->buffer_file_coding_system; | 4638 val = current_buffer->buffer_file_coding_system; |
4640 using_default_coding = 1; | 4639 using_default_coding = 1; |
4656 val = call3 (Vselect_safe_coding_system_function, start, end, val); | 4655 val = call3 (Vselect_safe_coding_system_function, start, end, val); |
4657 | 4656 |
4658 /* If the decided coding-system doesn't specify end-of-line | 4657 /* If the decided coding-system doesn't specify end-of-line |
4659 format, we use that of | 4658 format, we use that of |
4660 `default-buffer-file-coding-system'. */ | 4659 `default-buffer-file-coding-system'. */ |
4661 if (! using_default_coding) | 4660 if (! using_default_coding |
4661 && ! NILP (buffer_defaults.buffer_file_coding_system)) | |
4662 val = (coding_inherit_eol_type | 4662 val = (coding_inherit_eol_type |
4663 (val, buffer_defaults.buffer_file_coding_system)); | 4663 (val, buffer_defaults.buffer_file_coding_system)); |
4664 | 4664 |
4665 /* If we decide not to encode text, use `raw-text' or one of its | 4665 /* If we decide not to encode text, use `raw-text' or one of its |
4666 subsidiaries. */ | 4666 subsidiaries. */ |
4667 if (force_raw_text) | 4667 if (force_raw_text) |
4668 val = raw_text_coding_system (val); | 4668 val = raw_text_coding_system (val); |
4669 } | 4669 } |
4670 | 4670 |
4671 setup_coding_system (Fcheck_coding_system (val), coding); | 4671 setup_coding_system (val, coding); |
4672 if (! NILP (val) | |
4673 && VECTORP (CODING_ID_EOL_TYPE (coding->id))) | |
4674 val = AREF (CODING_ID_EOL_TYPE (coding->id), 0); | |
4672 | 4675 |
4673 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) | 4676 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) |
4674 coding->mode |= CODING_MODE_SELECTIVE_DISPLAY; | 4677 coding->mode |= CODING_MODE_SELECTIVE_DISPLAY; |
4678 return val; | |
4675 } | 4679 } |
4676 | 4680 |
4677 DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7, | 4681 DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7, |
4678 "r\nFWrite region to file: \ni\ni\ni\np", | 4682 "r\nFWrite region to file: \ni\ni\ni\np", |
4679 doc: /* Write current region into specified file. | 4683 doc: /* Write current region into specified file. |
4805 | 4809 |
4806 /* Decide the coding-system to encode the data with. | 4810 /* Decide the coding-system to encode the data with. |
4807 We used to make this choice before calling build_annotations, but that | 4811 We used to make this choice before calling build_annotations, but that |
4808 leads to problems when a write-annotate-function takes care of | 4812 leads to problems when a write-annotate-function takes care of |
4809 unsavable chars (as was the case with X-Symbol). */ | 4813 unsavable chars (as was the case with X-Symbol). */ |
4810 choose_write_coding_system (start, end, filename, | 4814 Vlast_coding_system_used |
4811 append, visit, lockname, &coding); | 4815 = choose_write_coding_system (start, end, filename, |
4812 Vlast_coding_system_used = CODING_ID_NAME (coding.id); | 4816 append, visit, lockname, &coding); |
4813 | 4817 |
4814 given_buffer = current_buffer; | 4818 given_buffer = current_buffer; |
4815 if (current_buffer != given_buffer) | 4819 if (current_buffer != given_buffer) |
4816 { | 4820 { |
4817 XSETFASTINT (start, BEGV); | 4821 XSETFASTINT (start, BEGV); |