comparison src/fileio.c @ 51357:4830e98be217

(Qauto_save_coding, auto_save_coding): New variables. (Finsert_file_contents): If coding-system-for-read is bound to Qauto_save_coding, use the coding system emacs-mule with special setting for recovering a file. (choose_write_coding_system): On auto saving, use the coding system emacs-mule with special setting for auto saving. (syms_of_fileio) <Qauto_save_coding>: Intern and staticpro it.
author Kenichi Handa <handa@m17n.org>
date Sat, 31 May 2003 01:58:13 +0000
parents 66b3b1b70da3
children 3df5bc22c5e4
comparison
equal deleted inserted replaced
51356:8da3b8a0ca4f 51357:4830e98be217
151 int auto_saving; 151 int auto_saving;
152 152
153 /* Set by auto_save_1 to mode of original file so Fwrite_region will create 153 /* Set by auto_save_1 to mode of original file so Fwrite_region will create
154 a new file with the same mode as the original */ 154 a new file with the same mode as the original */
155 int auto_save_mode_bits; 155 int auto_save_mode_bits;
156
157 /* The symbol bound to coding-system-for-read when
158 insert-file-contents is called for recovering a file. This is not
159 an actual coding system name, but just an indicator to tell
160 insert-file-contents to use `emacs-mule' with a special flag for
161 auto saving and recovering a file. */
162 Lisp_Object Qauto_save_coding;
156 163
157 /* Coding system for file names, or nil if none. */ 164 /* Coding system for file names, or nil if none. */
158 Lisp_Object Vfile_name_coding_system; 165 Lisp_Object Vfile_name_coding_system;
159 166
160 /* Coding system for file names used only when 167 /* Coding system for file names used only when
3762 if (st.st_size == 0) 3769 if (st.st_size == 0)
3763 XSETINT (end, READ_BUF_SIZE); 3770 XSETINT (end, READ_BUF_SIZE);
3764 } 3771 }
3765 } 3772 }
3766 3773
3767 if (BEG < Z) 3774 if (EQ (Vcoding_system_for_read, Qauto_save_coding))
3775 {
3776 /* We use emacs-mule for auto saving... */
3777 setup_coding_system (Qemacs_mule, &coding);
3778 /* ... but with the special flag to indicate to read in a
3779 multibyte sequence for eight-bit-control char as is. */
3780 coding.flags = 1;
3781 coding.src_multibyte = 0;
3782 coding.dst_multibyte
3783 = !NILP (current_buffer->enable_multibyte_characters);
3784 coding.eol_type = CODING_EOL_LF;
3785 coding_system_decided = 1;
3786 }
3787 else if (BEG < Z)
3768 { 3788 {
3769 /* Decide the coding system to use for reading the file now 3789 /* Decide the coding system to use for reading the file now
3770 because we can't use an optimized method for handling 3790 because we can't use an optimized method for handling
3771 `coding:' tag if the current buffer is not empty. */ 3791 `coding:' tag if the current buffer is not empty. */
3772 Lisp_Object val; 3792 Lisp_Object val;
4661 struct coding_system *coding; 4681 struct coding_system *coding;
4662 { 4682 {
4663 Lisp_Object val; 4683 Lisp_Object val;
4664 4684
4665 if (auto_saving) 4685 if (auto_saving)
4666 val = Qnil; 4686 {
4687 /* We use emacs-mule for auto saving... */
4688 setup_coding_system (Qemacs_mule, coding);
4689 /* ... but with the special flag to indicate not to strip off
4690 leading code of eight-bit-control chars. */
4691 coding->flags = 1;
4692 goto done_setup_coding;
4693 }
4667 else if (!NILP (Vcoding_system_for_write)) 4694 else if (!NILP (Vcoding_system_for_write))
4668 { 4695 {
4669 val = Vcoding_system_for_write; 4696 val = Vcoding_system_for_write;
4670 if (coding_system_require_warning 4697 if (coding_system_require_warning
4671 && !NILP (Ffboundp (Vselect_safe_coding_system_function))) 4698 && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
6292 Qfile_newer_than_file_p = intern ("file-newer-than-file-p"); 6319 Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
6293 Qinsert_file_contents = intern ("insert-file-contents"); 6320 Qinsert_file_contents = intern ("insert-file-contents");
6294 Qwrite_region = intern ("write-region"); 6321 Qwrite_region = intern ("write-region");
6295 Qverify_visited_file_modtime = intern ("verify-visited-file-modtime"); 6322 Qverify_visited_file_modtime = intern ("verify-visited-file-modtime");
6296 Qset_visited_file_modtime = intern ("set-visited-file-modtime"); 6323 Qset_visited_file_modtime = intern ("set-visited-file-modtime");
6324 Qauto_save_coding = intern ("auto-save-coding");
6297 6325
6298 staticpro (&Qexpand_file_name); 6326 staticpro (&Qexpand_file_name);
6299 staticpro (&Qsubstitute_in_file_name); 6327 staticpro (&Qsubstitute_in_file_name);
6300 staticpro (&Qdirectory_file_name); 6328 staticpro (&Qdirectory_file_name);
6301 staticpro (&Qfile_name_directory); 6329 staticpro (&Qfile_name_directory);
6324 staticpro (&Qfile_newer_than_file_p); 6352 staticpro (&Qfile_newer_than_file_p);
6325 staticpro (&Qinsert_file_contents); 6353 staticpro (&Qinsert_file_contents);
6326 staticpro (&Qwrite_region); 6354 staticpro (&Qwrite_region);
6327 staticpro (&Qverify_visited_file_modtime); 6355 staticpro (&Qverify_visited_file_modtime);
6328 staticpro (&Qset_visited_file_modtime); 6356 staticpro (&Qset_visited_file_modtime);
6357 staticpro (&Qauto_save_coding);
6329 6358
6330 Qfile_name_history = intern ("file-name-history"); 6359 Qfile_name_history = intern ("file-name-history");
6331 Fset (Qfile_name_history, Qnil); 6360 Fset (Qfile_name_history, Qnil);
6332 staticpro (&Qfile_name_history); 6361 staticpro (&Qfile_name_history);
6333 6362