diff options
| author | Glenn Morris | 2014-08-10 17:38:19 -0700 |
|---|---|---|
| committer | Glenn Morris | 2014-08-10 17:38:19 -0700 |
| commit | f314e84fce8b394da20aa1d69121c74fb34f9a1e (patch) | |
| tree | 214ada74bd8ae7e7450d5269b03cdf51ed87d11d | |
| parent | db2f09ab1be010a06a88269d39fb14c191452f1c (diff) | |
| download | emacs-f314e84fce8b394da20aa1d69121c74fb34f9a1e.tar.gz emacs-f314e84fce8b394da20aa1d69121c74fb34f9a1e.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/files.el | 13 | ||||
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/fileio.c | 36 | ||||
| -rw-r--r-- | test/ChangeLog | 6 | ||||
| -rw-r--r-- | test/automated/data/files-bug18141.el.gz | bin | 0 -> 77 bytes | |||
| -rw-r--r-- | test/automated/files.el | 18 |
7 files changed, 53 insertions, 36 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cec6e709c2b..ba8dac2c4e9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-08-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * files.el (basic-save-buffer-2): Revert 2013-01-31 change, which | ||
| 4 | chose coding system for writing before backing up, since it causes | ||
| 5 | a more serious problem than the one it solves. (Closes Bug#18141, | ||
| 6 | reopens Bug#13522.) | ||
| 7 | |||
| 1 | 2014-08-10 Martin Rudalics <rudalics@gmx.at> | 8 | 2014-08-10 Martin Rudalics <rudalics@gmx.at> |
| 2 | 9 | ||
| 3 | * window.el (window-total-size): Make doc-string more | 10 | * window.el (window-total-size): Make doc-string more |
diff --git a/lisp/files.el b/lisp/files.el index 6c3b8f4fa4d..5ed5f8a6e1e 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4756,7 +4756,7 @@ Before and after saving the buffer, this function runs | |||
| 4756 | ;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like | 4756 | ;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like |
| 4757 | ;; backup-buffer. | 4757 | ;; backup-buffer. |
| 4758 | (defun basic-save-buffer-2 () | 4758 | (defun basic-save-buffer-2 () |
| 4759 | (let (tempsetmodes setmodes writecoding) | 4759 | (let (tempsetmodes setmodes) |
| 4760 | (if (not (file-writable-p buffer-file-name)) | 4760 | (if (not (file-writable-p buffer-file-name)) |
| 4761 | (let ((dir (file-name-directory buffer-file-name))) | 4761 | (let ((dir (file-name-directory buffer-file-name))) |
| 4762 | (if (not (file-directory-p dir)) | 4762 | (if (not (file-directory-p dir)) |
| @@ -4772,14 +4772,6 @@ Before and after saving the buffer, this function runs | |||
| 4772 | buffer-file-name))) | 4772 | buffer-file-name))) |
| 4773 | (setq tempsetmodes t) | 4773 | (setq tempsetmodes t) |
| 4774 | (error "Attempt to save to a file which you aren't allowed to write")))))) | 4774 | (error "Attempt to save to a file which you aren't allowed to write")))))) |
| 4775 | ;; This may involve prompting, so do it now before backing up the file. | ||
| 4776 | ;; Otherwise there can be a delay while the user answers the | ||
| 4777 | ;; prompt during which the original file has been renamed. (Bug#13522) | ||
| 4778 | (setq writecoding | ||
| 4779 | ;; Args here should match write-region call below around | ||
| 4780 | ;; which we use writecoding. | ||
| 4781 | (choose-write-coding-system nil nil buffer-file-name nil t | ||
| 4782 | buffer-file-truename)) | ||
| 4783 | (or buffer-backed-up | 4775 | (or buffer-backed-up |
| 4784 | (setq setmodes (backup-buffer))) | 4776 | (setq setmodes (backup-buffer))) |
| 4785 | (let* ((dir (file-name-directory buffer-file-name)) | 4777 | (let* ((dir (file-name-directory buffer-file-name)) |
| @@ -4861,11 +4853,10 @@ Before and after saving the buffer, this function runs | |||
| 4861 | (logior (car setmodes) 128)))))) | 4853 | (logior (car setmodes) 128)))))) |
| 4862 | (let (success) | 4854 | (let (success) |
| 4863 | (unwind-protect | 4855 | (unwind-protect |
| 4856 | (progn | ||
| 4864 | ;; Pass in nil&nil rather than point-min&max to indicate | 4857 | ;; Pass in nil&nil rather than point-min&max to indicate |
| 4865 | ;; we're saving the buffer rather than just a region. | 4858 | ;; we're saving the buffer rather than just a region. |
| 4866 | ;; write-region-annotate-functions may make us of it. | 4859 | ;; write-region-annotate-functions may make us of it. |
| 4867 | (let ((coding-system-for-write writecoding) | ||
| 4868 | (coding-system-require-warning nil)) | ||
| 4869 | (write-region nil nil | 4860 | (write-region nil nil |
| 4870 | buffer-file-name nil t buffer-file-truename) | 4861 | buffer-file-name nil t buffer-file-truename) |
| 4871 | (setq success t)) | 4862 | (setq success t)) |
diff --git a/src/ChangeLog b/src/ChangeLog index 6ecce26be14..92d90accc60 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-08-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * fileio.c: Revert 2013-01-31 change, which chose coding system for | ||
| 4 | writing before backing up, since it causes a more serious problem | ||
| 5 | than the one it solves. (Closes Bug#18141, reopens Bug#13522.) | ||
| 6 | (choose_write_coding_system): No longer callable from Lisp. | ||
| 7 | Move last piece back here from Fwrite_region. | ||
| 8 | (Fwrite_region, syms_of_fileio): Update for above changes. | ||
| 9 | |||
| 1 | 2014-08-09 Martin Rudalics <rudalics@gmx.at> | 10 | 2014-08-09 Martin Rudalics <rudalics@gmx.at> |
| 2 | 11 | ||
| 3 | * window.c (Fwindow_new_total, Fwindow_new_normal) | 12 | * window.c (Fwindow_new_total, Fwindow_new_normal) |
diff --git a/src/fileio.c b/src/fileio.c index c87a6f71312..261928dd821 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -323,7 +323,6 @@ static Lisp_Object Qfile_acl; | |||
| 323 | static Lisp_Object Qset_file_acl; | 323 | static Lisp_Object Qset_file_acl; |
| 324 | static Lisp_Object Qfile_newer_than_file_p; | 324 | static Lisp_Object Qfile_newer_than_file_p; |
| 325 | Lisp_Object Qinsert_file_contents; | 325 | Lisp_Object Qinsert_file_contents; |
| 326 | static Lisp_Object Qchoose_write_coding_system; | ||
| 327 | Lisp_Object Qwrite_region; | 326 | Lisp_Object Qwrite_region; |
| 328 | static Lisp_Object Qverify_visited_file_modtime; | 327 | static Lisp_Object Qverify_visited_file_modtime; |
| 329 | static Lisp_Object Qset_visited_file_modtime; | 328 | static Lisp_Object Qset_visited_file_modtime; |
| @@ -4531,24 +4530,14 @@ build_annotations_unwind (Lisp_Object arg) | |||
| 4531 | 4530 | ||
| 4532 | /* Decide the coding-system to encode the data with. */ | 4531 | /* Decide the coding-system to encode the data with. */ |
| 4533 | 4532 | ||
| 4534 | DEFUN ("choose-write-coding-system", Fchoose_write_coding_system, | 4533 | static Lisp_Object |
| 4535 | Schoose_write_coding_system, 3, 6, 0, | 4534 | choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object filename, |
| 4536 | doc: /* Choose the coding system for writing a file. | 4535 | Lisp_Object append, Lisp_Object visit, Lisp_Object lockname, |
| 4537 | Arguments are as for `write-region'. | 4536 | struct coding_system *coding) |
| 4538 | This function is for internal use only. It may prompt the user. */ ) | ||
| 4539 | (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | ||
| 4540 | Lisp_Object append, Lisp_Object visit, Lisp_Object lockname) | ||
| 4541 | { | 4537 | { |
| 4542 | Lisp_Object val; | 4538 | Lisp_Object val; |
| 4543 | Lisp_Object eol_parent = Qnil; | 4539 | Lisp_Object eol_parent = Qnil; |
| 4544 | 4540 | ||
| 4545 | /* Mimic write-region behavior. */ | ||
| 4546 | if (NILP (start)) | ||
| 4547 | { | ||
| 4548 | XSETFASTINT (start, BEGV); | ||
| 4549 | XSETFASTINT (end, ZV); | ||
| 4550 | } | ||
| 4551 | |||
| 4552 | if (auto_saving | 4541 | if (auto_saving |
| 4553 | && NILP (Fstring_equal (BVAR (current_buffer, filename), | 4542 | && NILP (Fstring_equal (BVAR (current_buffer, filename), |
| 4554 | BVAR (current_buffer, auto_save_file_name)))) | 4543 | BVAR (current_buffer, auto_save_file_name)))) |
| @@ -4641,6 +4630,10 @@ This function is for internal use only. It may prompt the user. */ ) | |||
| 4641 | } | 4630 | } |
| 4642 | 4631 | ||
| 4643 | val = coding_inherit_eol_type (val, eol_parent); | 4632 | val = coding_inherit_eol_type (val, eol_parent); |
| 4633 | setup_coding_system (val, coding); | ||
| 4634 | |||
| 4635 | if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display))) | ||
| 4636 | coding->mode |= CODING_MODE_SELECTIVE_DISPLAY; | ||
| 4644 | return val; | 4637 | return val; |
| 4645 | } | 4638 | } |
| 4646 | 4639 | ||
| @@ -4809,14 +4802,9 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 4809 | We used to make this choice before calling build_annotations, but that | 4802 | We used to make this choice before calling build_annotations, but that |
| 4810 | leads to problems when a write-annotate-function takes care of | 4803 | leads to problems when a write-annotate-function takes care of |
| 4811 | unsavable chars (as was the case with X-Symbol). */ | 4804 | unsavable chars (as was the case with X-Symbol). */ |
| 4812 | Vlast_coding_system_used = | 4805 | Vlast_coding_system_used |
| 4813 | Fchoose_write_coding_system (start, end, filename, | 4806 | = choose_write_coding_system (start, end, filename, |
| 4814 | append, visit, lockname); | 4807 | append, visit, lockname, &coding); |
| 4815 | |||
| 4816 | setup_coding_system (Vlast_coding_system_used, &coding); | ||
| 4817 | |||
| 4818 | if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display))) | ||
| 4819 | coding.mode |= CODING_MODE_SELECTIVE_DISPLAY; | ||
| 4820 | 4808 | ||
| 4821 | #ifdef CLASH_DETECTION | 4809 | #ifdef CLASH_DETECTION |
| 4822 | if (open_and_close_file && !auto_saving) | 4810 | if (open_and_close_file && !auto_saving) |
| @@ -5861,7 +5849,6 @@ syms_of_fileio (void) | |||
| 5861 | DEFSYM (Qset_file_acl, "set-file-acl"); | 5849 | DEFSYM (Qset_file_acl, "set-file-acl"); |
| 5862 | DEFSYM (Qfile_newer_than_file_p, "file-newer-than-file-p"); | 5850 | DEFSYM (Qfile_newer_than_file_p, "file-newer-than-file-p"); |
| 5863 | DEFSYM (Qinsert_file_contents, "insert-file-contents"); | 5851 | DEFSYM (Qinsert_file_contents, "insert-file-contents"); |
| 5864 | DEFSYM (Qchoose_write_coding_system, "choose-write-coding-system"); | ||
| 5865 | DEFSYM (Qwrite_region, "write-region"); | 5852 | DEFSYM (Qwrite_region, "write-region"); |
| 5866 | DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime"); | 5853 | DEFSYM (Qverify_visited_file_modtime, "verify-visited-file-modtime"); |
| 5867 | DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime"); | 5854 | DEFSYM (Qset_visited_file_modtime, "set-visited-file-modtime"); |
| @@ -6100,7 +6087,6 @@ This includes interactive calls to `delete-file' and | |||
| 6100 | defsubr (&Sdefault_file_modes); | 6087 | defsubr (&Sdefault_file_modes); |
| 6101 | defsubr (&Sfile_newer_than_file_p); | 6088 | defsubr (&Sfile_newer_than_file_p); |
| 6102 | defsubr (&Sinsert_file_contents); | 6089 | defsubr (&Sinsert_file_contents); |
| 6103 | defsubr (&Schoose_write_coding_system); | ||
| 6104 | defsubr (&Swrite_region); | 6090 | defsubr (&Swrite_region); |
| 6105 | defsubr (&Scar_less_than_car); | 6091 | defsubr (&Scar_less_than_car); |
| 6106 | defsubr (&Sverify_visited_file_modtime); | 6092 | defsubr (&Sverify_visited_file_modtime); |
diff --git a/test/ChangeLog b/test/ChangeLog index d68c5b6bb07..d5c5e58f09c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-08-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * automated/data/files-bug18141.el.gz: New file. | ||
| 4 | * automated/files.el (files-test-bug-18141-file): | ||
| 5 | New variable and test. (Bug#18141) | ||
| 6 | |||
| 1 | 2014-08-07 Glenn Morris <rgm@gnu.org> | 7 | 2014-08-07 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * automated/Makefile.in (check-tar): Remove, no longer needed. | 9 | * automated/Makefile.in (check-tar): Remove, no longer needed. |
diff --git a/test/automated/data/files-bug18141.el.gz b/test/automated/data/files-bug18141.el.gz new file mode 100644 index 00000000000..53d463e85b5 --- /dev/null +++ b/test/automated/data/files-bug18141.el.gz | |||
| Binary files differ | |||
diff --git a/test/automated/files.el b/test/automated/files.el index 44816bc33f5..8db06f7dfe3 100644 --- a/test/automated/files.el +++ b/test/automated/files.el | |||
| @@ -148,6 +148,24 @@ form.") | |||
| 148 | (should (file-test--do-local-variables-test str subtest)))))) | 148 | (should (file-test--do-local-variables-test str subtest)))))) |
| 149 | (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) | 149 | (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test))) |
| 150 | 150 | ||
| 151 | (defvar files-test-bug-18141-file | ||
| 152 | (expand-file-name "data/files-bug18141.el.gz" (getenv "EMACS_TEST_DIRECTORY")) | ||
| 153 | "Test file for bug#18141.") | ||
| 154 | |||
| 155 | (ert-deftest files-test-bug-18141 () | ||
| 156 | "Test for http://debbugs.gnu.org/18141 ." | ||
| 157 | (skip-unless (executable-find "gzip")) | ||
| 158 | (let ((tempfile (make-temp-file "files-test-bug-18141" nil ".gz"))) | ||
| 159 | (unwind-protect | ||
| 160 | (progn | ||
| 161 | (copy-file files-test-bug-18141-file tempfile t) | ||
| 162 | (with-current-buffer (find-file-noselect tempfile) | ||
| 163 | (set-buffer-modified-p t) | ||
| 164 | (save-buffer) | ||
| 165 | (should (eq buffer-file-coding-system 'iso-2022-7bit-unix)))) | ||
| 166 | (delete-file tempfile)))) | ||
| 167 | |||
| 168 | |||
| 151 | ;; Stop the above "Local Var..." confusing Emacs. | 169 | ;; Stop the above "Local Var..." confusing Emacs. |
| 152 | 170 | ||
| 153 | 171 | ||