comparison src/fileio.c @ 18185:d84dde1fad16

(Fwrite_region): Cancel the 7th argument CODING_SYSTEM added by the previous change. (auto_save_1): Adjusted for the above change.
author Kenichi Handa <handa@m17n.org>
date Mon, 09 Jun 1997 12:59:52 +0000
parents 7e13abad5cca
children 2338261796d2
comparison
equal deleted inserted replaced
18184:ef6ecf102af3 18185:d84dde1fad16
3744 Fset_buffer (buf); 3744 Fset_buffer (buf);
3745 Fkill_buffer (tembuf); 3745 Fkill_buffer (tembuf);
3746 return Qnil; 3746 return Qnil;
3747 } 3747 }
3748 3748
3749 DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7, 3749 DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 6,
3750 "r\nFWrite region to file: \ni\ni\ni\nZCoding system: ", 3750 "r\nFWrite region to file: ",
3751 "Write current region into specified file.\n\ 3751 "Write current region into specified file.\n\
3752 When called from a program, takes three arguments:\n\ 3752 When called from a program, takes three arguments:\n\
3753 START, END and FILENAME. START and END are buffer positions.\n\ 3753 START, END and FILENAME. START and END are buffer positions.\n\
3754 Optional fourth argument APPEND if non-nil means\n\ 3754 Optional fourth argument APPEND if non-nil means\n\
3755 append to existing file contents (if any).\n\ 3755 append to existing file contents (if any).\n\
3760 the output goes to FILENAME, but the buffer is marked as visiting VISIT.\n\ 3760 the output goes to FILENAME, but the buffer is marked as visiting VISIT.\n\
3761 VISIT is also the file name to lock and unlock for clash detection.\n\ 3761 VISIT is also the file name to lock and unlock for clash detection.\n\
3762 If VISIT is neither t nor nil nor a string,\n\ 3762 If VISIT is neither t nor nil nor a string,\n\
3763 that means do not print the \"Wrote file\" message.\n\ 3763 that means do not print the \"Wrote file\" message.\n\
3764 The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\ 3764 The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\
3765 use for locking and unlocking, overriding FILENAME and VISIT.\n\
3766 The optional seventh arg CODING-SYSTEM, if non-nil, specifies the coding\n\
3767 system to be used for encoding characters. For interactive use,\n\
3768 you can specify it by giving a prefix argument. If no coding system\n\
3769 is specified, the current region is encoded according to the value of\n\
3770 `coding-system-for-write' or `coding-system-alist'. The variable\n\
3771 `last-coding-system-used' is set the coding system actually used.\n\
3772 Kludgy feature: if START is a string, then that string is written\n\ 3765 Kludgy feature: if START is a string, then that string is written\n\
3773 to the file, instead of any buffer contents, and END is ignored.") 3766 to the file, instead of any buffer contents, and END is ignored.")
3774 (start, end, filename, append, visit, lockname, coding_system_symbol) 3767 (start, end, filename, append, visit, lockname)
3775 Lisp_Object start, end, filename, append, visit, lockname; 3768 Lisp_Object start, end, filename, append, visit, lockname;
3776 Lisp_Object coding_system_symbol;
3777 { 3769 {
3778 register int desc; 3770 register int desc;
3779 int failure; 3771 int failure;
3780 int save_errno; 3772 int save_errno;
3781 unsigned char *fn; 3773 unsigned char *fn;
3802 error ("Cannot do file visiting in an indirect buffer"); 3794 error ("Cannot do file visiting in an indirect buffer");
3803 3795
3804 if (!NILP (start) && !STRINGP (start)) 3796 if (!NILP (start) && !STRINGP (start))
3805 validate_region (&start, &end); 3797 validate_region (&start, &end);
3806 3798
3807 GCPRO5 (start, filename, visit, lockname, coding_system_symbol); 3799 GCPRO4 (start, filename, visit, lockname);
3808 3800
3809 /* Decide the coding-system to be encoded to. */ 3801 /* Decide the coding-system to be encoded to. */
3810 { 3802 {
3811 Lisp_Object val; 3803 Lisp_Object val;
3812 3804
3813 if (auto_saving || NILP (current_buffer->enable_multibyte_characters)) 3805 if (auto_saving || NILP (current_buffer->enable_multibyte_characters))
3814 val = Qnil; 3806 val = Qnil;
3815 else if (!NILP (coding_system_symbol))
3816 val = coding_system_symbol;
3817 else if (!NILP (Vcoding_system_for_write)) 3807 else if (!NILP (Vcoding_system_for_write))
3818 val = Vcoding_system_for_write; 3808 val = Vcoding_system_for_write;
3819 else if (!NILP (Flocal_variable_if_set_p (Qbuffer_file_coding_system, 3809 else if (!NILP (Flocal_variable_if_set_p (Qbuffer_file_coding_system,
3820 Qnil))) 3810 Qnil)))
3821 val = Fsymbol_value (Qbuffer_file_coding_system); 3811 val = Fsymbol_value (Qbuffer_file_coding_system);
3827 args[3] = filename, args[4] = append, args[5] = visit, 3817 args[3] = filename, args[4] = append, args[5] = visit,
3828 args[6] = lockname; 3818 args[6] = lockname;
3829 coding_systems = Ffind_coding_system (7, args); 3819 coding_systems = Ffind_coding_system (7, args);
3830 val = (CONSP (coding_systems) 3820 val = (CONSP (coding_systems)
3831 ? XCONS (coding_systems)->cdr 3821 ? XCONS (coding_systems)->cdr
3832 : Fsymbol_value (Qbuffer_file_coding_system)); 3822 : current_buffer->buffer_file_coding_system);
3833 } 3823 }
3834 setup_coding_system (Fcheck_coding_system (val), &coding); 3824 setup_coding_system (Fcheck_coding_system (val), &coding);
3835 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) 3825 if (!STRINGP (start) && !NILP (current_buffer->selective_display))
3836 coding.selective = 1; 3826 coding.selective = 1;
3837 #ifdef DOS_NT 3827 #ifdef DOS_NT
4455 auto_save_mode_bits = 0666; 4445 auto_save_mode_bits = 0666;
4456 4446
4457 return 4447 return
4458 Fwrite_region (Qnil, Qnil, 4448 Fwrite_region (Qnil, Qnil,
4459 current_buffer->auto_save_file_name, 4449 current_buffer->auto_save_file_name,
4460 Qnil, Qlambda, Qnil, Qnil); 4450 Qnil, Qlambda, Qnil);
4461 } 4451 }
4462 4452
4463 static Lisp_Object 4453 static Lisp_Object
4464 do_auto_save_unwind (desc) /* used as unwind-protect function */ 4454 do_auto_save_unwind (desc) /* used as unwind-protect function */
4465 Lisp_Object desc; 4455 Lisp_Object desc;