diff options
| author | Glenn Morris <rgm@gnu.org> | 2013-01-30 22:35:45 -0800 |
|---|---|---|
| committer | Glenn Morris <rgm@gnu.org> | 2013-01-30 22:35:45 -0800 |
| commit | 9dbda100755158fd070931748f2b80ad09bc6815 (patch) | |
| tree | 4051909615adf3e1c618976602e66a2cbcc23a6e /lisp/files.el | |
| parent | ad4de702e19bf1a8065cb84b6eefbc68190d9c3f (diff) | |
| download | emacs-9dbda100755158fd070931748f2b80ad09bc6815.tar.gz | |
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/files.el')
| -rw-r--r-- | lisp/files.el | 13 |
1 files changed, 11 insertions, 2 deletions
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 ;; This returns a value (MODES EXTENDED-ATTRIBUTES BACKUPNAME), like ;; backup-buffer. (defun basic-save-buffer-2 () - (let (tempsetmodes setmodes) + (let (tempsetmodes setmodes writecoding) (if (not (file-writable-p buffer-file-name)) (let ((dir (file-name-directory buffer-file-name))) (if (not (file-directory-p dir)) @@ -4672,6 +4672,14 @@ 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)) @@ -4753,10 +4761,11 @@ 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)) |
