Mercurial > emacs
comparison src/fileio.c @ 18861:ed1871a409c8
(Finsert_file_contents) [DOS_NT]: Use the coding
system to determine buffer_file_type.
(Fwrite_region): Only use Qbuffer_file_coding_system
before checking file-coding-system-alist if non-nil.
(Fwrite_region) [DOS_NT]: Delete conditional code.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 18 Jul 1997 22:56:16 +0000 |
parents | 2ef1d8539441 |
children | 9f5b8d5eed29 |
comparison
equal
deleted
inserted
replaced
18860:f55d91d45bde | 18861:ed1871a409c8 |
---|---|
195 Lisp_Object Vdirectory_sep_char; | 195 Lisp_Object Vdirectory_sep_char; |
196 | 196 |
197 extern Lisp_Object Vuser_login_name; | 197 extern Lisp_Object Vuser_login_name; |
198 | 198 |
199 extern int minibuf_level; | 199 extern int minibuf_level; |
200 | |
201 extern int minibuffer_auto_raise; | |
200 | 202 |
201 /* These variables describe handlers that have "already" had a chance | 203 /* These variables describe handlers that have "already" had a chance |
202 to handle the current operation. | 204 to handle the current operation. |
203 | 205 |
204 Vinhibit_file_name_handlers is a list of file name handlers. | 206 Vinhibit_file_name_handlers is a list of file name handlers. |
3079 val = CONSP (coding_systems) ? XCONS (coding_systems)->car : Qnil; | 3081 val = CONSP (coding_systems) ? XCONS (coding_systems)->car : Qnil; |
3080 } | 3082 } |
3081 setup_coding_system (Fcheck_coding_system (val), &coding); | 3083 setup_coding_system (Fcheck_coding_system (val), &coding); |
3082 } | 3084 } |
3083 | 3085 |
3086 #ifdef DOS_NT | |
3087 /* Use the conversion type to determine buffer-file-type | |
3088 (find-buffer-file-type is now used to help determine the | |
3089 conversion). */ | |
3090 if (coding.type == coding_type_no_conversion) | |
3091 current_buffer->buffer_file_type = Qt; | |
3092 else | |
3093 current_buffer->buffer_file_type = Qnil; | |
3094 #endif | |
3095 | |
3084 fd = -1; | 3096 fd = -1; |
3085 | 3097 |
3086 #ifndef APOLLO | 3098 #ifndef APOLLO |
3087 if (stat (XSTRING (filename)->data, &st) < 0) | 3099 if (stat (XSTRING (filename)->data, &st) < 0) |
3088 #else | 3100 #else |
3817 | 3829 |
3818 if (auto_saving) | 3830 if (auto_saving) |
3819 val = Qnil; | 3831 val = Qnil; |
3820 else if (!NILP (Vcoding_system_for_write)) | 3832 else if (!NILP (Vcoding_system_for_write)) |
3821 val = Vcoding_system_for_write; | 3833 val = Vcoding_system_for_write; |
3822 else if (NILP (current_buffer->enable_multibyte_characters) | 3834 else if (NILP (current_buffer->enable_multibyte_characters) || |
3823 || !NILP (Flocal_variable_if_set_p (Qbuffer_file_coding_system, | 3835 ! NILP (Fsymbol_value (Qbuffer_file_coding_system))) |
3824 Qnil))) | |
3825 val = Fsymbol_value (Qbuffer_file_coding_system); | 3836 val = Fsymbol_value (Qbuffer_file_coding_system); |
3826 else | 3837 else |
3827 { | 3838 { |
3828 Lisp_Object args[7], coding_systems; | 3839 Lisp_Object args[7], coding_systems; |
3829 | 3840 |
3836 : current_buffer->buffer_file_coding_system); | 3847 : current_buffer->buffer_file_coding_system); |
3837 } | 3848 } |
3838 setup_coding_system (Fcheck_coding_system (val), &coding); | 3849 setup_coding_system (Fcheck_coding_system (val), &coding); |
3839 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) | 3850 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) |
3840 coding.selective = 1; | 3851 coding.selective = 1; |
3841 #ifdef DOS_NT | |
3842 if (!NILP (current_buffer->buffer_file_type)) | |
3843 coding.eol_type = CODING_EOL_LF; | |
3844 #endif /* DOS_NT */ | |
3845 } | 3852 } |
3846 | 3853 |
3847 filename = Fexpand_file_name (filename, Qnil); | 3854 filename = Fexpand_file_name (filename, Qnil); |
3848 if (STRINGP (visit)) | 3855 if (STRINGP (visit)) |
3849 visit_file = Fexpand_file_name (visit, Qnil); | 3856 visit_file = Fexpand_file_name (visit, Qnil); |
4473 fclose ((FILE *) (XFASTINT (XCONS (stream)->car) << 16 | 4480 fclose ((FILE *) (XFASTINT (XCONS (stream)->car) << 16 |
4474 | XFASTINT (XCONS (stream)->cdr))); | 4481 | XFASTINT (XCONS (stream)->cdr))); |
4475 return Qnil; | 4482 return Qnil; |
4476 } | 4483 } |
4477 | 4484 |
4485 static Lisp_Object | |
4486 do_auto_save_unwind_1 (value) /* used as unwind-protect function */ | |
4487 Lisp_Object value; | |
4488 { | |
4489 minibuffer_auto_raise = XINT (value); | |
4490 return Qnil; | |
4491 } | |
4492 | |
4478 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", | 4493 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", |
4479 "Auto-save all buffers that need it.\n\ | 4494 "Auto-save all buffers that need it.\n\ |
4480 This is all buffers that have auto-saving enabled\n\ | 4495 This is all buffers that have auto-saving enabled\n\ |
4481 and are changed since last auto-saved.\n\ | 4496 and are changed since last auto-saved.\n\ |
4482 Auto-saving writes the buffer into a file\n\ | 4497 Auto-saving writes the buffer into a file\n\ |
4497 Lisp_Object oquit; | 4512 Lisp_Object oquit; |
4498 FILE *stream; | 4513 FILE *stream; |
4499 Lisp_Object lispstream; | 4514 Lisp_Object lispstream; |
4500 int count = specpdl_ptr - specpdl; | 4515 int count = specpdl_ptr - specpdl; |
4501 int *ptr; | 4516 int *ptr; |
4517 int orig_minibuffer_auto_raise = minibuffer_auto_raise; | |
4502 | 4518 |
4503 /* Ordinarily don't quit within this function, | 4519 /* Ordinarily don't quit within this function, |
4504 but don't make it impossible to quit (in case we get hung in I/O). */ | 4520 but don't make it impossible to quit (in case we get hung in I/O). */ |
4505 oquit = Vquit_flag; | 4521 oquit = Vquit_flag; |
4506 Vquit_flag = Qnil; | 4522 Vquit_flag = Qnil; |
4531 stream = NULL; | 4547 stream = NULL; |
4532 lispstream = Qnil; | 4548 lispstream = Qnil; |
4533 } | 4549 } |
4534 | 4550 |
4535 record_unwind_protect (do_auto_save_unwind, lispstream); | 4551 record_unwind_protect (do_auto_save_unwind, lispstream); |
4536 | 4552 record_unwind_protect (do_auto_save_unwind_1, |
4553 make_number (minibuffer_auto_raise)); | |
4554 minibuffer_auto_raise = 0; | |
4537 auto_saving = 1; | 4555 auto_saving = 1; |
4538 | 4556 |
4539 /* First, save all files which don't have handlers. If Emacs is | 4557 /* First, save all files which don't have handlers. If Emacs is |
4540 crashing, the handlers may tweak what is causing Emacs to crash | 4558 crashing, the handlers may tweak what is causing Emacs to crash |
4541 in the first place, and it would be a shame if Emacs failed to | 4559 in the first place, and it would be a shame if Emacs failed to |
4602 /* These messages are frequent and annoying for `*mail*'. */ | 4620 /* These messages are frequent and annoying for `*mail*'. */ |
4603 && !EQ (b->filename, Qnil) | 4621 && !EQ (b->filename, Qnil) |
4604 && NILP (no_message)) | 4622 && NILP (no_message)) |
4605 { | 4623 { |
4606 /* It has shrunk too much; turn off auto-saving here. */ | 4624 /* It has shrunk too much; turn off auto-saving here. */ |
4625 minibuffer_auto_raise = orig_minibuffer_auto_raise; | |
4607 message ("Buffer %s has shrunk a lot; auto save turned off there", | 4626 message ("Buffer %s has shrunk a lot; auto save turned off there", |
4608 XSTRING (b->name)->data); | 4627 XSTRING (b->name)->data); |
4628 minibuffer_auto_raise = 0; | |
4609 /* Turn off auto-saving until there's a real save, | 4629 /* Turn off auto-saving until there's a real save, |
4610 and prevent any more warnings. */ | 4630 and prevent any more warnings. */ |
4611 XSETINT (b->save_length, -1); | 4631 XSETINT (b->save_length, -1); |
4612 Fsleep_for (make_number (1), Qnil); | 4632 Fsleep_for (make_number (1), Qnil); |
4613 continue; | 4633 continue; |
4864 | 4884 |
4865 GCPRO2 (insdef, default_filename); | 4885 GCPRO2 (insdef, default_filename); |
4866 val = Fcompleting_read (prompt, intern ("read-file-name-internal"), | 4886 val = Fcompleting_read (prompt, intern ("read-file-name-internal"), |
4867 dir, mustmatch, insdef1, | 4887 dir, mustmatch, insdef1, |
4868 Qfile_name_history, default_filename); | 4888 Qfile_name_history, default_filename); |
4889 /* If Fcompleting_read returned the default string itself | |
4890 (rather than a new string with the same contents), | |
4891 it has to mean that the user typed RET with the minibuffer empty. | |
4892 In that case, we really want to return "" | |
4893 so that commands such as set-visited-file-name can distinguish. */ | |
4894 if (EQ (val, default_filename)) | |
4895 val = build_string (""); | |
4869 | 4896 |
4870 #ifdef VMS | 4897 #ifdef VMS |
4871 unbind_to (count, Qnil); | 4898 unbind_to (count, Qnil); |
4872 #endif | 4899 #endif |
4873 | 4900 |