diff options
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/src/fileio.c b/src/fileio.c index f0bd75b170e..d9c7397c2de 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -323,7 +323,6 @@ static Lisp_Object Qfile_acl; static Lisp_Object Qset_file_acl; static Lisp_Object Qfile_newer_than_file_p; Lisp_Object Qinsert_file_contents; -static Lisp_Object Qchoose_write_coding_system; Lisp_Object Qwrite_region; static Lisp_Object Qverify_visited_file_modtime; static Lisp_Object Qset_visited_file_modtime; @@ -4525,24 +4524,14 @@ build_annotations_unwind (Lisp_Object arg) /* Decide the coding-system to encode the data with. */ -DEFUN ("choose-write-coding-system", Fchoose_write_coding_system, - Schoose_write_coding_system, 3, 6, 0, - doc: /* Choose the coding system for writing a file. -Arguments are as for `write-region'. -This function is for internal use only. It may prompt the user. */ ) - (Lisp_Object start, Lisp_Object end, Lisp_Object filename, - Lisp_Object append, Lisp_Object visit, Lisp_Object lockname) +static Lisp_Object +choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object filename, + Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, + struct coding_system *coding) { Lisp_Object val; Lisp_Object eol_parent = Qnil; - /* Mimic write-region behavior. */ - if (NILP (start)) - { - XSETFASTINT (start, BEGV); - XSETFASTINT (end, ZV); - } - if (auto_saving && NILP (Fstring_equal (BVAR (current_buffer, filename), BVAR (current_buffer, auto_save_file_name)))) @@ -4635,6 +4624,10 @@ This function is for internal use only. It may prompt the user. */ ) } val = coding_inherit_eol_type (val, eol_parent); + setup_coding_system (val, coding); + + if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display))) + coding->mode |= CODING_MODE_SELECTIVE_DISPLAY; return val; } @@ -4803,14 +4796,9 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, We used to make this choice before calling build_annotations, but that leads to problems when a write-annotate-function takes care of unsavable chars (as was the case with X-Symbol). */ - Vlast_coding_system_used = - Fchoose_write_coding_system (start, end, filename, - append, visit, lockname); - - setup_coding_system (Vlast_coding_system_used, &coding); - - if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display))) - coding.mode |= CODING_MODE_SELECTIVE_DISPLAY; + Vlast_coding_system_used + = choose_write_coding_system (start, end, filename, + append, visit, lockname, &coding); if (open_and_close_file && !auto_saving) { @@ -5829,7 +5817,6 @@ syms_of_fileio (void) DEFSYM (Qset_file_acl, "set-file-acl"); DEFSYM (Qfile_newer_than_file_p, "file-newer-than-file-p"); DEFSYM (Qinsert_file_contents, "insert-file-contents"); - DEFSYM (Qchoose_write_coding_system, "choose-write-coding-system"); DEFSYM (Qwrite_region, "write-region"); DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime"); DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime"); @@ -6068,7 +6055,6 @@ This includes interactive calls to `delete-file' and defsubr (&Sdefault_file_modes); defsubr (&Sfile_newer_than_file_p); defsubr (&Sinsert_file_contents); - defsubr (&Schoose_write_coding_system); defsubr (&Swrite_region); defsubr (&Scar_less_than_car); defsubr (&Sverify_visited_file_modtime); |