+ if (! coding_system_decided)
+ {
+ /* The coding system is not yet decided. Decide it by an
+ optimized method for handling `coding:' tag. */
+ Lisp_Object val;
+ val = Qnil;
+
+ if (!NILP (Vcoding_system_for_read))
+ val = Vcoding_system_for_read;
+ else
+ {
+ if (inserted > 0 && ! NILP (Vset_auto_coding_function))
+ {
+ /* Since we are sure that the current buffer was
+ empty before the insertion, we can toggle
+ enable-multibyte-characters directly here without
+ taking care of marker adjustment and byte
+ combining problem. */
+ Lisp_Object prev_multibyte;
+ int count = specpdl_ptr - specpdl;
+
+ prev_multibyte = current_buffer->enable_multibyte_characters;
+ current_buffer->enable_multibyte_characters = Qnil;
+ record_unwind_protect (set_auto_coding_unwind,
+ prev_multibyte);
+ val = call2 (Vset_auto_coding_function,
+ filename, make_number (inserted));
+ /* Discard the unwind protect for recovering the
+ error of Vset_auto_coding_function. */
+ specpdl_ptr--;
+ current_buffer->enable_multibyte_characters = prev_multibyte;
+ TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
+ }
+
+ if (NILP (val))
+ {
+ /* If the coding system is not yet decided, check
+ file-coding-system-alist. */
+ Lisp_Object args[6], coding_systems;
+
+ args[0] = Qinsert_file_contents, args[1] = orig_filename;
+ args[2] = visit, args[3] = beg, args[4] = end, args[5] = Qnil;
+ coding_systems = Ffind_operation_coding_system (6, args);
+ if (CONSP (coding_systems))
+ val = XCAR (coding_systems);
+ }
+ }
+
+ /* The following kludgy code is to avoid some compiler bug.
+ We can't simply do
+ setup_coding_system (val, &coding);
+ on some system. */
+ {
+ struct coding_system temp_coding;
+ setup_coding_system (val, &temp_coding);
+ bcopy (&temp_coding, &coding, sizeof coding);
+ }
+
+ if (NILP (current_buffer->enable_multibyte_characters)
+ && ! NILP (val))
+ /* We must suppress all character code conversion except for
+ end-of-line conversion. */
+ setup_raw_text_coding_system (&coding);
+ }
+
+ if (inserted > 0 || coding.type == coding_type_ccl)