diff options
| author | Kenichi Handa | 1998-07-25 04:23:13 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-07-25 04:23:13 +0000 |
| commit | 1255deb9a63c9020290ac96c7cedae8f8176c4d0 (patch) | |
| tree | b7a2ffced7acbb4b499ac496306c732c4b847109 /src | |
| parent | 47e1dcfee1eaadebef070e28688097f0f6772781 (diff) | |
| download | emacs-1255deb9a63c9020290ac96c7cedae8f8176c4d0.tar.gz emacs-1255deb9a63c9020290ac96c7cedae8f8176c4d0.zip | |
(Finsert_file_contents): Call Vset_auto_coding_function
with two arguments.
(Fwrite_region): If buffer-file-coding-system is set locally, use
the coding system whithout checking file-coding-system-alist.
(syms_of_fileio): Docstring of set-auto-coding-function adjusted
for the change of argument number.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/src/fileio.c b/src/fileio.c index e3ca6cd4e2a..d9ad61cdcdc 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3503,7 +3503,8 @@ actually used.") | |||
| 3503 | current_buffer->enable_multibyte_characters = Qnil; | 3503 | current_buffer->enable_multibyte_characters = Qnil; |
| 3504 | insert_1_both (read_buf, nread, nread, 0, 0, 0); | 3504 | insert_1_both (read_buf, nread, nread, 0, 0, 0); |
| 3505 | TEMP_SET_PT_BOTH (BEG, BEG_BYTE); | 3505 | TEMP_SET_PT_BOTH (BEG, BEG_BYTE); |
| 3506 | val = call1 (Vset_auto_coding_function, make_number (nread)); | 3506 | val = call2 (Vset_auto_coding_function, |
| 3507 | filename, make_number (nread)); | ||
| 3507 | set_buffer_internal (prev); | 3508 | set_buffer_internal (prev); |
| 3508 | /* Discard the unwind protect for recovering the | 3509 | /* Discard the unwind protect for recovering the |
| 3509 | current buffer. */ | 3510 | current buffer. */ |
| @@ -4034,8 +4035,8 @@ actually used.") | |||
| 4034 | current_buffer->enable_multibyte_characters = Qnil; | 4035 | current_buffer->enable_multibyte_characters = Qnil; |
| 4035 | record_unwind_protect (set_auto_coding_unwind, | 4036 | record_unwind_protect (set_auto_coding_unwind, |
| 4036 | prev_multibyte); | 4037 | prev_multibyte); |
| 4037 | val = call1 (Vset_auto_coding_function, | 4038 | val = call2 (Vset_auto_coding_function, |
| 4038 | make_number (inserted)); | 4039 | filename, make_number (inserted)); |
| 4039 | /* Discard the unwind protect for recovering the | 4040 | /* Discard the unwind protect for recovering the |
| 4040 | error of Vset_auto_coding_function. */ | 4041 | error of Vset_auto_coding_function. */ |
| 4041 | specpdl_ptr--; | 4042 | specpdl_ptr--; |
| @@ -4291,7 +4292,7 @@ This does code conversion according to the value of\n\ | |||
| 4291 | val = Qnil; | 4292 | val = Qnil; |
| 4292 | else if (!NILP (Vcoding_system_for_write)) | 4293 | else if (!NILP (Vcoding_system_for_write)) |
| 4293 | val = Vcoding_system_for_write; | 4294 | val = Vcoding_system_for_write; |
| 4294 | else if (NILP (current_buffer->enable_multibyte_characters)) | 4295 | else |
| 4295 | { | 4296 | { |
| 4296 | /* If the variable `buffer-file-coding-system' is set locally, | 4297 | /* If the variable `buffer-file-coding-system' is set locally, |
| 4297 | it means that the file was read with some kind of code | 4298 | it means that the file was read with some kind of code |
| @@ -4303,37 +4304,42 @@ This does code conversion according to the value of\n\ | |||
| 4303 | format if the default value of `buffer-file-coding-system' | 4304 | format if the default value of `buffer-file-coding-system' |
| 4304 | tells that it is not Unix-like (LF only) format. */ | 4305 | tells that it is not Unix-like (LF only) format. */ |
| 4305 | val = current_buffer->buffer_file_coding_system; | 4306 | val = current_buffer->buffer_file_coding_system; |
| 4306 | if (NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil))) | 4307 | if (NILP (val) |
| 4308 | || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil))) | ||
| 4307 | { | 4309 | { |
| 4308 | struct coding_system coding_temp; | 4310 | if (NILP (current_buffer->enable_multibyte_characters)) |
| 4309 | |||
| 4310 | setup_coding_system (Fcheck_coding_system (val), &coding_temp); | ||
| 4311 | if (coding_temp.eol_type == CODING_EOL_CRLF | ||
| 4312 | || coding_temp.eol_type == CODING_EOL_CR) | ||
| 4313 | { | 4311 | { |
| 4314 | setup_coding_system (Qraw_text, &coding); | 4312 | setup_coding_system (Fcheck_coding_system (val), &coding); |
| 4315 | coding.eol_type = coding_temp.eol_type; | 4313 | setup_raw_text_coding_system (&coding); |
| 4316 | goto done_setup_coding; | 4314 | goto done_setup_coding; |
| 4317 | } | 4315 | } |
| 4318 | val = Qnil; | 4316 | val = Qnil; |
| 4319 | } | 4317 | } |
| 4320 | } | 4318 | |
| 4321 | else | 4319 | if (NILP (val)) |
| 4322 | { | 4320 | { |
| 4323 | Lisp_Object args[7], coding_systems; | 4321 | /* Check file-coding-system-alist. */ |
| 4324 | 4322 | Lisp_Object args[7], coding_systems; | |
| 4325 | args[0] = Qwrite_region; args[1] = start; args[2] = end; | 4323 | |
| 4326 | args[3] = filename; args[4] = append; args[5] = visit; | 4324 | args[0] = Qwrite_region; args[1] = start; args[2] = end; |
| 4327 | args[6] = lockname; | 4325 | args[3] = filename; args[4] = append; args[5] = visit; |
| 4328 | coding_systems = Ffind_operation_coding_system (7, args); | 4326 | args[6] = lockname; |
| 4329 | val = (CONSP (coding_systems) && !NILP (XCONS (coding_systems)->cdr) | 4327 | coding_systems = Ffind_operation_coding_system (7, args); |
| 4330 | ? XCONS (coding_systems)->cdr | 4328 | if (CONSP (coding_systems) && !NILP (XCONS (coding_systems)->cdr)) |
| 4331 | : current_buffer->buffer_file_coding_system); | 4329 | val = XCONS (coding_systems)->cdr; |
| 4332 | /* Confirm that VAL can surely encode the current region. */ | 4330 | } |
| 4333 | if (!NILP (Ffboundp (Vselect_safe_coding_system_function))) | 4331 | |
| 4332 | if (NILP (val)) | ||
| 4333 | /* If we still have not decided a coding system, use the | ||
| 4334 | default value of buffer-file-coding-system. */ | ||
| 4335 | val = current_buffer->buffer_file_coding_system; | ||
| 4336 | |||
| 4337 | if (! NILP (val) | ||
| 4338 | && !NILP (Ffboundp (Vselect_safe_coding_system_function))) | ||
| 4339 | /* Confirm that VAL can surely encode the current region. */ | ||
| 4334 | val = call3 (Vselect_safe_coding_system_function, start, end, val); | 4340 | val = call3 (Vselect_safe_coding_system_function, start, end, val); |
| 4335 | } | 4341 | } |
| 4336 | setup_coding_system (Fcheck_coding_system (val), &coding); | 4342 | setup_coding_system (Fcheck_coding_system (val), &coding); |
| 4337 | 4343 | ||
| 4338 | done_setup_coding: | 4344 | done_setup_coding: |
| 4339 | if (!STRINGP (start) && !NILP (current_buffer->selective_display)) | 4345 | if (!STRINGP (start) && !NILP (current_buffer->selective_display)) |
| @@ -5646,9 +5652,11 @@ for its argument."); | |||
| 5646 | DEFVAR_LISP ("set-auto-coding-function", | 5652 | DEFVAR_LISP ("set-auto-coding-function", |
| 5647 | &Vset_auto_coding_function, | 5653 | &Vset_auto_coding_function, |
| 5648 | "If non-nil, a function to call to decide a coding system of file.\n\ | 5654 | "If non-nil, a function to call to decide a coding system of file.\n\ |
| 5649 | One argument is passed to this function: the length of a file contents\n\ | 5655 | Two arguments are passed to this function: the file name\n\ |
| 5650 | following the point.\n\ | 5656 | and the length of a file contents following the point.\n\ |
| 5651 | This function should return a coding system to decode the file contents\n\ | 5657 | This function should return a coding system to decode the file contents.\n\ |
| 5658 | It should check the file name against `auto-coding-alist'.\n\ | ||
| 5659 | If no coding system is decided, it should check a coding system\n\ | ||
| 5652 | specified in the heading lines with the format:\n\ | 5660 | specified in the heading lines with the format:\n\ |
| 5653 | -*- ... coding: CODING-SYSTEM; ... -*-\n\ | 5661 | -*- ... coding: CODING-SYSTEM; ... -*-\n\ |
| 5654 | or local variable spec of the tailing lines with `coding:' tag."); | 5662 | or local variable spec of the tailing lines with `coding:' tag."); |