4604 |
Lisp_Object val; |
Lisp_Object val; |
4605 |
|
|
4606 |
if (auto_saving) |
if (auto_saving) |
4607 |
val = Qnil; |
val = Qnil; |
4608 |
else if (!NILP (Vcoding_system_for_write)) |
else if (!NILP (Vcoding_system_for_write)) |
4609 |
val = Vcoding_system_for_write; |
val = Vcoding_system_for_write; |
4610 |
else |
else |
4611 |
{ |
{ |
4612 |
/* If the variable `buffer-file-coding-system' is set locally, |
/* If the variable `buffer-file-coding-system' is set locally, |
4613 |
it means that the file was read with some kind of code |
it means that the file was read with some kind of code |
4614 |
conversion or the variable is explicitly set by users. We |
conversion or the variable is explicitly set by users. We |
4615 |
had better write it out with the same coding system even if |
had better write it out with the same coding system even if |
4616 |
`enable-multibyte-characters' is nil. |
`enable-multibyte-characters' is nil. |
4617 |
|
|
4618 |
If it is not set locally, we anyway have to convert EOL |
If it is not set locally, we anyway have to convert EOL |
4619 |
format if the default value of `buffer-file-coding-system' |
format if the default value of `buffer-file-coding-system' |
4620 |
tells that it is not Unix-like (LF only) format. */ |
tells that it is not Unix-like (LF only) format. */ |
4621 |
int using_default_coding = 0; |
int using_default_coding = 0; |
4622 |
int force_raw_text = 0; |
int force_raw_text = 0; |
4623 |
|
|
4624 |
val = current_buffer->buffer_file_coding_system; |
val = current_buffer->buffer_file_coding_system; |
4625 |
if (NILP (val) |
if (NILP (val) |
4626 |
|| NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil))) |
|| NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil))) |
4627 |
{ |
{ |
4628 |
val = Qnil; |
val = Qnil; |
4629 |
if (NILP (current_buffer->enable_multibyte_characters)) |
if (NILP (current_buffer->enable_multibyte_characters)) |
4630 |
force_raw_text = 1; |
force_raw_text = 1; |
4631 |
} |
} |
4632 |
|
|
4633 |
if (NILP (val)) |
if (NILP (val)) |
4634 |
{ |
{ |
4635 |
/* Check file-coding-system-alist. */ |
/* Check file-coding-system-alist. */ |
4636 |
Lisp_Object args[7], coding_systems; |
Lisp_Object args[7], coding_systems; |
4637 |
|
|
4638 |
args[0] = Qwrite_region; args[1] = start; args[2] = end; |
args[0] = Qwrite_region; args[1] = start; args[2] = end; |
4639 |
args[3] = filename; args[4] = append; args[5] = visit; |
args[3] = filename; args[4] = append; args[5] = visit; |
4640 |
args[6] = lockname; |
args[6] = lockname; |
4641 |
coding_systems = Ffind_operation_coding_system (7, args); |
coding_systems = Ffind_operation_coding_system (7, args); |
4642 |
if (CONSP (coding_systems) && !NILP (XCDR (coding_systems))) |
if (CONSP (coding_systems) && !NILP (XCDR (coding_systems))) |
4643 |
val = XCDR (coding_systems); |
val = XCDR (coding_systems); |
4644 |
} |
} |
4645 |
|
|
4646 |
if (NILP (val) |
if (NILP (val) |
4647 |
&& !NILP (current_buffer->buffer_file_coding_system)) |
&& !NILP (current_buffer->buffer_file_coding_system)) |
4648 |
{ |
{ |
4649 |
/* If we still have not decided a coding system, use the |
/* If we still have not decided a coding system, use the |
4650 |
default value of buffer-file-coding-system. */ |
default value of buffer-file-coding-system. */ |
4651 |
val = current_buffer->buffer_file_coding_system; |
val = current_buffer->buffer_file_coding_system; |
4652 |
using_default_coding = 1; |
using_default_coding = 1; |
4653 |
} |
} |
4654 |
|
|
4655 |
if (!force_raw_text |
if (!force_raw_text |
4656 |
&& !NILP (Ffboundp (Vselect_safe_coding_system_function))) |
&& !NILP (Ffboundp (Vselect_safe_coding_system_function))) |
4657 |
/* Confirm that VAL can surely encode the current region. */ |
/* Confirm that VAL can surely encode the current region. */ |
4658 |
val = call3 (Vselect_safe_coding_system_function, start, end, val); |
val = call3 (Vselect_safe_coding_system_function, start, end, val); |
4659 |
|
|
4662 |
&& !using_default_coding) |
&& !using_default_coding) |
4663 |
{ |
{ |
4664 |
if (! EQ (default_buffer_file_coding.symbol, |
if (! EQ (default_buffer_file_coding.symbol, |
4665 |
buffer_defaults.buffer_file_coding_system)) |
buffer_defaults.buffer_file_coding_system)) |
4666 |
setup_coding_system (buffer_defaults.buffer_file_coding_system, |
setup_coding_system (buffer_defaults.buffer_file_coding_system, |
4667 |
&default_buffer_file_coding); |
&default_buffer_file_coding); |
4668 |
if (default_buffer_file_coding.eol_type != CODING_EOL_UNDECIDED) |
if (default_buffer_file_coding.eol_type != CODING_EOL_UNDECIDED) |
4669 |
{ |
{ |
4670 |
Lisp_Object subsidiaries; |
Lisp_Object subsidiaries; |
4671 |
|
|
6170 |
inserted at the specified positions of the file being written (1 means to\n\ |
inserted at the specified positions of the file being written (1 means to\n\ |
6171 |
insert before the first byte written). The POSITIONs must be sorted into\n\ |
insert before the first byte written). The POSITIONs must be sorted into\n\ |
6172 |
increasing order. If there are several functions in the list, the several\n\ |
increasing order. If there are several functions in the list, the several\n\ |
6173 |
lists are merged destructively."); |
lists are merged destructively. Alternatively, the function can return\n\ |
6174 |
|
with a different buffer current and value nil."); |
6175 |
Vwrite_region_annotate_functions = Qnil; |
Vwrite_region_annotate_functions = Qnil; |
6176 |
|
|
6177 |
DEFVAR_LISP ("write-region-annotations-so-far", |
DEFVAR_LISP ("write-region-annotations-so-far", |