diff options
| author | Kenichi Handa | 2003-05-31 01:58:13 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-05-31 01:58:13 +0000 |
| commit | 356a62243ab2d0201462c23121749c2d9bbf359e (patch) | |
| tree | e441241bc8ccc900d2983dd1c8e39f7cda389734 | |
| parent | fd3ae0b9def77d98c4936581f7d0ab004bdde16e (diff) | |
| download | emacs-356a62243ab2d0201462c23121749c2d9bbf359e.tar.gz emacs-356a62243ab2d0201462c23121749c2d9bbf359e.zip | |
(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.
| -rw-r--r-- | src/fileio.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c index c84298cdaf1..b308a4b3852 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -154,6 +154,13 @@ int auto_saving; | |||
| 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 | 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; | ||
| 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 | ||
| @@ -3764,7 +3771,20 @@ actually used. */) | |||
| 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 |
| @@ -4663,7 +4683,14 @@ choose_write_coding_system (start, end, filename, | |||
| 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; |
| @@ -6294,6 +6321,7 @@ syms_of_fileio () | |||
| 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); |
| @@ -6326,6 +6354,7 @@ syms_of_fileio () | |||
| 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); |