mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-02 11:21:42 +00:00
Revert 2013-01-31 change that decides coding system before backing up
It causes a more serious problem than the one it solves. This closes bug#18141, and reopens bug#13522. * lisp/files.el (basic-save-buffer-2): Revert 2013-01-31 change. * src/fileio.c: Revert 2013-01-31 change. (choose_write_coding_system): No longer callable from Lisp. Move last piece back here from Fwrite_region. (Fwrite_region, syms_of_fileio): Update for above changes. * test/automated/data/files-bug18141.el.gz: New file. * test/automated/files.el (files-test-bug-18141-file): New variable and test.
This commit is contained in:
parent
db2f09ab1b
commit
f314e84fce
@ -1,3 +1,10 @@
|
||||
2014-08-11 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* files.el (basic-save-buffer-2): Revert 2013-01-31 change, which
|
||||
chose coding system for writing before backing up, since it causes
|
||||
a more serious problem than the one it solves. (Closes Bug#18141,
|
||||
reopens Bug#13522.)
|
||||
|
||||
2014-08-10 Martin Rudalics <rudalics@gmx.at>
|
||||
|
||||
* window.el (window-total-size): Make doc-string more
|
||||
|
@ -4756,7 +4756,7 @@ Before and after saving the buffer, this function runs
|
||||
;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like
|
||||
;; backup-buffer.
|
||||
(defun basic-save-buffer-2 ()
|
||||
(let (tempsetmodes setmodes writecoding)
|
||||
(let (tempsetmodes setmodes)
|
||||
(if (not (file-writable-p buffer-file-name))
|
||||
(let ((dir (file-name-directory buffer-file-name)))
|
||||
(if (not (file-directory-p dir))
|
||||
@ -4772,14 +4772,6 @@ Before and after saving the buffer, this function runs
|
||||
buffer-file-name)))
|
||||
(setq tempsetmodes t)
|
||||
(error "Attempt to save to a file which you aren't allowed to write"))))))
|
||||
;; This may involve prompting, so do it now before backing up the file.
|
||||
;; Otherwise there can be a delay while the user answers the
|
||||
;; prompt during which the original file has been renamed. (Bug#13522)
|
||||
(setq writecoding
|
||||
;; Args here should match write-region call below around
|
||||
;; which we use writecoding.
|
||||
(choose-write-coding-system nil nil buffer-file-name nil t
|
||||
buffer-file-truename))
|
||||
(or buffer-backed-up
|
||||
(setq setmodes (backup-buffer)))
|
||||
(let* ((dir (file-name-directory buffer-file-name))
|
||||
@ -4861,11 +4853,10 @@ Before and after saving the buffer, this function runs
|
||||
(logior (car setmodes) 128))))))
|
||||
(let (success)
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; Pass in nil&nil rather than point-min&max to indicate
|
||||
;; we're saving the buffer rather than just a region.
|
||||
;; write-region-annotate-functions may make us of it.
|
||||
(let ((coding-system-for-write writecoding)
|
||||
(coding-system-require-warning nil))
|
||||
(write-region nil nil
|
||||
buffer-file-name nil t buffer-file-truename)
|
||||
(setq success t))
|
||||
|
@ -1,3 +1,12 @@
|
||||
2014-08-11 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* fileio.c: Revert 2013-01-31 change, which chose coding system for
|
||||
writing before backing up, since it causes a more serious problem
|
||||
than the one it solves. (Closes Bug#18141, reopens Bug#13522.)
|
||||
(choose_write_coding_system): No longer callable from Lisp.
|
||||
Move last piece back here from Fwrite_region.
|
||||
(Fwrite_region, syms_of_fileio): Update for above changes.
|
||||
|
||||
2014-08-09 Martin Rudalics <rudalics@gmx.at>
|
||||
|
||||
* window.c (Fwindow_new_total, Fwindow_new_normal)
|
||||
|
36
src/fileio.c
36
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;
|
||||
@ -4531,24 +4530,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))))
|
||||
@ -4641,6 +4630,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;
|
||||
}
|
||||
|
||||
@ -4809,14 +4802,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);
|
||||
|
||||
#ifdef CLASH_DETECTION
|
||||
if (open_and_close_file && !auto_saving)
|
||||
@ -5861,7 +5849,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");
|
||||
@ -6100,7 +6087,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);
|
||||
|
@ -1,3 +1,9 @@
|
||||
2014-08-11 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* automated/data/files-bug18141.el.gz: New file.
|
||||
* automated/files.el (files-test-bug-18141-file):
|
||||
New variable and test. (Bug#18141)
|
||||
|
||||
2014-08-07 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* automated/Makefile.in (check-tar): Remove, no longer needed.
|
||||
|
BIN
test/automated/data/files-bug18141.el.gz
Normal file
BIN
test/automated/data/files-bug18141.el.gz
Normal file
Binary file not shown.
@ -148,6 +148,24 @@ form.")
|
||||
(should (file-test--do-local-variables-test str subtest))))))
|
||||
(ad-disable-advice 'hack-local-variables-confirm 'around 'files-test)))
|
||||
|
||||
(defvar files-test-bug-18141-file
|
||||
(expand-file-name "data/files-bug18141.el.gz" (getenv "EMACS_TEST_DIRECTORY"))
|
||||
"Test file for bug#18141.")
|
||||
|
||||
(ert-deftest files-test-bug-18141 ()
|
||||
"Test for http://debbugs.gnu.org/18141 ."
|
||||
(skip-unless (executable-find "gzip"))
|
||||
(let ((tempfile (make-temp-file "files-test-bug-18141" nil ".gz")))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(copy-file files-test-bug-18141-file tempfile t)
|
||||
(with-current-buffer (find-file-noselect tempfile)
|
||||
(set-buffer-modified-p t)
|
||||
(save-buffer)
|
||||
(should (eq buffer-file-coding-system 'iso-2022-7bit-unix))))
|
||||
(delete-file tempfile))))
|
||||
|
||||
|
||||
;; Stop the above "Local Var..." confusing Emacs.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user