diff options
| author | Kenichi Handa | 1998-07-06 01:47:34 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-07-06 01:47:34 +0000 |
| commit | 2df42e09659b920a3777f61653d7386a84b2b04e (patch) | |
| tree | 140b0c2ca55aac452b06ea7ce386416213467bb2 /src | |
| parent | 18cc260b22f3e6463f23a195840abe220cc6ec4b (diff) | |
| download | emacs-2df42e09659b920a3777f61653d7386a84b2b04e.tar.gz emacs-2df42e09659b920a3777f61653d7386a84b2b04e.zip | |
(Finsert_file_contents): Cancel previous change. Setup
the variable coding even if the inserted bytes is zero.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/src/fileio.c b/src/fileio.c index b500bbe3b50..e444b1474d2 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3988,73 +3988,73 @@ actually used.") | |||
| 3988 | error ("IO error reading %s: %s", | 3988 | error ("IO error reading %s: %s", |
| 3989 | XSTRING (orig_filename)->data, strerror (errno)); | 3989 | XSTRING (orig_filename)->data, strerror (errno)); |
| 3990 | 3990 | ||
| 3991 | if (inserted > 0) | 3991 | if (! coding_system_decided) |
| 3992 | { | 3992 | { |
| 3993 | if (! coding_system_decided) | 3993 | /* The coding system is not yet decided. Decide it by an |
| 3994 | { | 3994 | optimized method for handling `coding:' tag. */ |
| 3995 | /* The coding system is not yet decided. Decide it by an | 3995 | Lisp_Object val; |
| 3996 | optimized method for handling `coding:' tag. */ | 3996 | val = Qnil; |
| 3997 | Lisp_Object val; | ||
| 3998 | val = Qnil; | ||
| 3999 | 3997 | ||
| 4000 | if (!NILP (Vcoding_system_for_read)) | 3998 | if (!NILP (Vcoding_system_for_read)) |
| 4001 | val = Vcoding_system_for_read; | 3999 | val = Vcoding_system_for_read; |
| 4002 | else | 4000 | else |
| 4001 | { | ||
| 4002 | if (inserted > 0 && ! NILP (Vset_auto_coding_function)) | ||
| 4003 | { | 4003 | { |
| 4004 | if (! NILP (Vset_auto_coding_function)) | 4004 | /* Since we are sure that the current buffer was |
| 4005 | { | 4005 | empty before the insertion, we can toggle |
| 4006 | /* Since we are sure that the current buffer was | 4006 | enable-multibyte-characters directly here without |
| 4007 | empty before the insertion, we can toggle | 4007 | taking care of marker adjustment and byte |
| 4008 | enable-multibyte-characters directly here without | 4008 | combining problem. */ |
| 4009 | taking care of marker adjustment and byte | 4009 | Lisp_Object prev_multibyte; |
| 4010 | combining problem. */ | 4010 | int count = specpdl_ptr - specpdl; |
| 4011 | Lisp_Object prev_multibyte; | 4011 | |
| 4012 | int count = specpdl_ptr - specpdl; | 4012 | prev_multibyte = current_buffer->enable_multibyte_characters; |
| 4013 | current_buffer->enable_multibyte_characters = Qnil; | ||
| 4014 | record_unwind_protect (set_auto_coding_unwind, | ||
| 4015 | prev_multibyte); | ||
| 4016 | val = call1 (Vset_auto_coding_function, | ||
| 4017 | make_number (inserted)); | ||
| 4018 | /* Discard the unwind protect for recovering the | ||
| 4019 | error of Vset_auto_coding_function. */ | ||
| 4020 | specpdl_ptr--; | ||
| 4021 | current_buffer->enable_multibyte_characters = prev_multibyte; | ||
| 4022 | TEMP_SET_PT_BOTH (BEG, BEG_BYTE); | ||
| 4023 | } | ||
| 4013 | 4024 | ||
| 4014 | prev_multibyte = current_buffer->enable_multibyte_characters; | 4025 | if (NILP (val)) |
| 4015 | current_buffer->enable_multibyte_characters = Qnil; | 4026 | { |
| 4016 | record_unwind_protect (set_auto_coding_unwind, | 4027 | /* If the coding system is not yet decided, check |
| 4017 | prev_multibyte); | 4028 | file-coding-system-alist. */ |
| 4018 | val = call1 (Vset_auto_coding_function, | 4029 | Lisp_Object args[6], coding_systems; |
| 4019 | make_number (inserted)); | ||
| 4020 | /* Discard the unwind protect for recovering the | ||
| 4021 | error of Vset_auto_coding_function. */ | ||
| 4022 | specpdl_ptr--; | ||
| 4023 | current_buffer->enable_multibyte_characters = prev_multibyte; | ||
| 4024 | TEMP_SET_PT_BOTH (BEG, BEG_BYTE); | ||
| 4025 | } | ||
| 4026 | 4030 | ||
| 4027 | if (NILP (val)) | 4031 | args[0] = Qinsert_file_contents, args[1] = orig_filename; |
| 4028 | { | 4032 | args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil; |
| 4029 | /* If the coding system is not yet decided, check | 4033 | coding_systems = Ffind_operation_coding_system (6, args); |
| 4030 | file-coding-system-alist. */ | 4034 | if (CONSP (coding_systems)) |
| 4031 | Lisp_Object args[6], coding_systems; | 4035 | val = XCONS (coding_systems)->car; |
| 4032 | |||
| 4033 | args[0] = Qinsert_file_contents, args[1] = orig_filename; | ||
| 4034 | args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil; | ||
| 4035 | coding_systems = Ffind_operation_coding_system (6, args); | ||
| 4036 | if (CONSP (coding_systems)) | ||
| 4037 | val = XCONS (coding_systems)->car; | ||
| 4038 | } | ||
| 4039 | } | 4036 | } |
| 4037 | } | ||
| 4040 | 4038 | ||
| 4041 | /* The following kludgy code is to avoid some compiler bug. | 4039 | /* The following kludgy code is to avoid some compiler bug. |
| 4042 | We can't simply do | 4040 | We can't simply do |
| 4043 | setup_coding_system (val, &coding); | 4041 | setup_coding_system (val, &coding); |
| 4044 | on some system. */ | 4042 | on some system. */ |
| 4045 | { | 4043 | { |
| 4046 | struct coding_system temp_coding; | 4044 | struct coding_system temp_coding; |
| 4047 | setup_coding_system (val, &temp_coding); | 4045 | setup_coding_system (val, &temp_coding); |
| 4048 | bcopy (&temp_coding, &coding, sizeof coding); | 4046 | bcopy (&temp_coding, &coding, sizeof coding); |
| 4049 | } | 4047 | } |
| 4050 | 4048 | ||
| 4051 | if (NILP (Vcoding_system_for_read) | 4049 | if (NILP (Vcoding_system_for_read) |
| 4052 | && NILP (current_buffer->enable_multibyte_characters)) | 4050 | && NILP (current_buffer->enable_multibyte_characters)) |
| 4053 | /* We must suppress all text conversion except for | 4051 | /* We must suppress all text conversion except for |
| 4054 | end-of-line conversion. */ | 4052 | end-of-line conversion. */ |
| 4055 | setup_raw_text_coding_system (&coding); | 4053 | setup_raw_text_coding_system (&coding); |
| 4056 | } | 4054 | } |
| 4057 | 4055 | ||
| 4056 | if (inserted > 0) | ||
| 4057 | { | ||
| 4058 | if (CODING_MAY_REQUIRE_DECODING (&coding)) | 4058 | if (CODING_MAY_REQUIRE_DECODING (&coding)) |
| 4059 | { | 4059 | { |
| 4060 | /* Here, we don't have to consider byte combining (see the | 4060 | /* Here, we don't have to consider byte combining (see the |
| @@ -4081,19 +4081,19 @@ actually used.") | |||
| 4081 | else | 4081 | else |
| 4082 | adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted, | 4082 | adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted, |
| 4083 | inserted); | 4083 | inserted); |
| 4084 | } | ||
| 4084 | 4085 | ||
| 4085 | #ifdef DOS_NT | 4086 | #ifdef DOS_NT |
| 4086 | /* Use the conversion type to determine buffer-file-type | 4087 | /* Use the conversion type to determine buffer-file-type |
| 4087 | (find-buffer-file-type is now used to help determine the | 4088 | (find-buffer-file-type is now used to help determine the |
| 4088 | conversion). */ | 4089 | conversion). */ |
| 4089 | if ((coding.eol_type == CODING_EOL_UNDECIDED | 4090 | if ((coding.eol_type == CODING_EOL_UNDECIDED |
| 4090 | || coding.eol_type == CODING_EOL_LF) | 4091 | || coding.eol_type == CODING_EOL_LF) |
| 4091 | && ! CODING_REQUIRE_DECODING (&coding)) | 4092 | && ! CODING_REQUIRE_DECODING (&coding)) |
| 4092 | current_buffer->buffer_file_type = Qt; | 4093 | current_buffer->buffer_file_type = Qt; |
| 4093 | else | 4094 | else |
| 4094 | current_buffer->buffer_file_type = Qnil; | 4095 | current_buffer->buffer_file_type = Qnil; |
| 4095 | #endif | 4096 | #endif |
| 4096 | } | ||
| 4097 | 4097 | ||
| 4098 | notfound: | 4098 | notfound: |
| 4099 | handled: | 4099 | handled: |
| @@ -4149,7 +4149,7 @@ actually used.") | |||
| 4149 | && (NILP (visit) || !NILP (replace))) | 4149 | && (NILP (visit) || !NILP (replace))) |
| 4150 | signal_after_change (PT, 0, inserted); | 4150 | signal_after_change (PT, 0, inserted); |
| 4151 | 4151 | ||
| 4152 | if (set_coding_system && inserted > 0) | 4152 | if (set_coding_system) |
| 4153 | Vlast_coding_system_used = coding.symbol; | 4153 | Vlast_coding_system_used = coding.symbol; |
| 4154 | 4154 | ||
| 4155 | if (inserted > 0) | 4155 | if (inserted > 0) |