aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGlenn Morris2013-01-30 22:35:45 -0800
committerGlenn Morris2013-01-30 22:35:45 -0800
commit9dbda100755158fd070931748f2b80ad09bc6815 (patch)
tree4051909615adf3e1c618976602e66a2cbcc23a6e /lisp
parentad4de702e19bf1a8065cb84b6eefbc68190d9c3f (diff)
downloademacs-9dbda100755158fd070931748f2b80ad09bc6815.tar.gz
emacs-9dbda100755158fd070931748f2b80ad09bc6815.zip
Reduce delay between backing up a file and saving new version
* lisp/files.el (basic-save-buffer-2): Choose coding system for writing the file before backing it up. * src/fileio.c (choose_write_coding_system): Make it callable from Lisp. (Fwrite_region): If coding-system-for-write is set, don't call choose_write_coding_system. Move the last piece of choose_write_coding_system here. (syms_of_fileio): Add choose-write-coding-system. Fixes: debbugs:13522
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/files.el13
2 files changed, 17 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6ac51724328..c1142a45e8d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-01-31 Glenn Morris <rgm@gnu.org>
2
3 * files.el (basic-save-buffer-2): Choose coding system for
4 writing the file before backing it up, to reduce delay between
5 backing up and writing the new version. (Bug#13522)
6
12013-01-31 Michal Nazarewicz <mina86@mina86.com> 72013-01-31 Michal Nazarewicz <mina86@mina86.com>
2 8
3 * simple.el (cycle-spacing): New command. 9 * simple.el (cycle-spacing): New command.
diff --git a/lisp/files.el b/lisp/files.el
index b015b53db3c..3bc3059c68f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4656,7 +4656,7 @@ Before and after saving the buffer, this function runs
4656;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like 4656;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like
4657;; backup-buffer. 4657;; backup-buffer.
4658(defun basic-save-buffer-2 () 4658(defun basic-save-buffer-2 ()
4659 (let (tempsetmodes setmodes) 4659 (let (tempsetmodes setmodes writecoding)
4660 (if (not (file-writable-p buffer-file-name)) 4660 (if (not (file-writable-p buffer-file-name))
4661 (let ((dir (file-name-directory buffer-file-name))) 4661 (let ((dir (file-name-directory buffer-file-name)))
4662 (if (not (file-directory-p dir)) 4662 (if (not (file-directory-p dir))
@@ -4672,6 +4672,14 @@ Before and after saving the buffer, this function runs
4672 buffer-file-name))) 4672 buffer-file-name)))
4673 (setq tempsetmodes t) 4673 (setq tempsetmodes t)
4674 (error "Attempt to save to a file which you aren't allowed to write")))))) 4674 (error "Attempt to save to a file which you aren't allowed to write"))))))
4675 ;; This may involve prompting, so do it now before backing up the file.
4676 ;; Otherwise there can be a delay while the user answers the
4677 ;; prompt during which the original file has been renamed. (Bug#13522)
4678 (setq writecoding
4679 ;; Args here should match write-region call below around
4680 ;; which we use writecoding.
4681 (choose-write-coding-system nil nil buffer-file-name nil t
4682 buffer-file-truename))
4675 (or buffer-backed-up 4683 (or buffer-backed-up
4676 (setq setmodes (backup-buffer))) 4684 (setq setmodes (backup-buffer)))
4677 (let* ((dir (file-name-directory buffer-file-name)) 4685 (let* ((dir (file-name-directory buffer-file-name))
@@ -4753,10 +4761,11 @@ Before and after saving the buffer, this function runs
4753 (logior (car setmodes) 128)))))) 4761 (logior (car setmodes) 128))))))
4754 (let (success) 4762 (let (success)
4755 (unwind-protect 4763 (unwind-protect
4756 (progn
4757 ;; Pass in nil&nil rather than point-min&max to indicate 4764 ;; Pass in nil&nil rather than point-min&max to indicate
4758 ;; we're saving the buffer rather than just a region. 4765 ;; we're saving the buffer rather than just a region.
4759 ;; write-region-annotate-functions may make us of it. 4766 ;; write-region-annotate-functions may make us of it.
4767 (let ((coding-system-for-write writecoding)
4768 (coding-system-require-warning nil))
4760 (write-region nil nil 4769 (write-region nil nil
4761 buffer-file-name nil t buffer-file-truename) 4770 buffer-file-name nil t buffer-file-truename)
4762 (setq success t)) 4771 (setq success t))