else if (!NILP (Vcoding_system_for_write))
val = Vcoding_system_for_write;
else if (NILP (current_buffer->enable_multibyte_characters))
- val = (NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil))
- ? Qnil
- : Fsymbol_value (Qbuffer_file_coding_system));
+ {
+ /* If the variable `buffer-file-coding-system' is set locally,
+ it means that the file was read with some kind of code
+ conversion or the varialbe is explicitely set by users. We
+ had better write it out with the same coding system even if
+ `enable-multibyte-characters' is nil.
+
+ If is is not set locally, we anyway have to convert EOL
+ format if the default value of `buffer-file-coding-system'
+ tells that it is not Unix-like (LF only) format. */
+ val = current_buffer->buffer_file_coding_system;
+ if (NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
+ {
+ struct coding_system coding_temp;
+
+ setup_coding_system (Fcheck_coding_system (val), &coding_temp);
+ if (coding_temp.eol_type == CODING_EOL_CRLF
+ || coding_temp.eol_type == CODING_EOL_CR)
+ {
+ setup_coding_system (Qemacs_mule, &coding);
+ coding.eol_type = coding_temp.eol_type;
+ goto done_setup_coding;
+ }
+ val = Qnil;
+ }
+ }
else
{
Lisp_Object args[7], coding_systems;
: current_buffer->buffer_file_coding_system);
}
setup_coding_system (Fcheck_coding_system (val), &coding);
+
+ done_setup_coding:
if (!STRINGP (start) && !NILP (current_buffer->selective_display))
coding.selective = 1;
}
GCPRO2 (insdef, default_filename);
val = Fcompleting_read (prompt, intern ("read-file-name-internal"),
dir, mustmatch, insdef1,
- Qfile_name_history, default_filename);
+ Qfile_name_history, default_filename, Qnil);
/* If Fcompleting_read returned the default string itself
(rather than a new string with the same contents),
it has to mean that the user typed RET with the minibuffer empty.
val = Fcompleting_read (prompt, intern ("read-file-name-internal"),
dir, mustmatch,
insert_default_directory ? insdef : Qnil,
- Qfile_name_history, Qnil);
+ Qfile_name_history, Qnil, Qnil);
#ifdef VMS
unbind_to (count, Qnil);