diff options
| author | Glenn Morris | 2013-02-20 21:44:06 -0500 |
|---|---|---|
| committer | Glenn Morris | 2013-02-20 21:44:06 -0500 |
| commit | b367ec7bc10f625cb9769bfca0b8f502cd475e22 (patch) | |
| tree | 31b64df85a01fe8e00a87853aa7b99f2b7d771bb | |
| parent | 2fce4cd861e5575fafb10525540cdc8580e134f1 (diff) | |
| download | emacs-b367ec7bc10f625cb9769bfca0b8f502cd475e22.tar.gz emacs-b367ec7bc10f625cb9769bfca0b8f502cd475e22.zip | |
* lisp/files.el (basic-save-buffer): Move check for existing parent directory
after hooks. (Bug#13773)
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/files.el | 18 |
2 files changed, 14 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index abcf6578060..7581b2a376c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-02-21 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * files.el (basic-save-buffer): Move check for existing parent | ||
| 4 | directory after hooks. (Bug#13773) | ||
| 5 | |||
| 1 | 2013-02-20 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2013-02-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * simple.el (command-execute): Move from C. Add obsolete check. | 8 | * simple.el (command-execute): Move from C. Add obsolete check. |
diff --git a/lisp/files.el b/lisp/files.el index f9ed65b8ac0..f9d02511839 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4563,15 +4563,8 @@ Before and after saving the buffer, this function runs | |||
| 4563 | (not (file-exists-p buffer-file-name)))) | 4563 | (not (file-exists-p buffer-file-name)))) |
| 4564 | (let ((recent-save (recent-auto-save-p)) | 4564 | (let ((recent-save (recent-auto-save-p)) |
| 4565 | setmodes) | 4565 | setmodes) |
| 4566 | (if buffer-file-name | ||
| 4567 | (let ((dir (file-name-directory | ||
| 4568 | (expand-file-name buffer-file-name)))) | ||
| 4569 | (unless (file-exists-p dir) | ||
| 4570 | (if (y-or-n-p | ||
| 4571 | (format "Directory `%s' does not exist; create? " dir)) | ||
| 4572 | (make-directory dir t) | ||
| 4573 | (error "Canceled")))) | ||
| 4574 | ;; If buffer has no file name, ask user for one. | 4566 | ;; If buffer has no file name, ask user for one. |
| 4567 | (or buffer-file-name | ||
| 4575 | (let ((filename | 4568 | (let ((filename |
| 4576 | (expand-file-name | 4569 | (expand-file-name |
| 4577 | (read-file-name "File to save in: " | 4570 | (read-file-name "File to save in: " |
| @@ -4628,7 +4621,14 @@ Before and after saving the buffer, this function runs | |||
| 4628 | (run-hook-with-args-until-success 'write-file-functions) | 4621 | (run-hook-with-args-until-success 'write-file-functions) |
| 4629 | ;; If a hook returned t, file is already "written". | 4622 | ;; If a hook returned t, file is already "written". |
| 4630 | ;; Otherwise, write it the usual way now. | 4623 | ;; Otherwise, write it the usual way now. |
| 4631 | (setq setmodes (basic-save-buffer-1))) | 4624 | (let ((dir (file-name-directory |
| 4625 | (expand-file-name buffer-file-name)))) | ||
| 4626 | (unless (file-exists-p dir) | ||
| 4627 | (if (y-or-n-p | ||
| 4628 | (format "Directory `%s' does not exist; create? " dir)) | ||
| 4629 | (make-directory dir t) | ||
| 4630 | (error "Canceled"))) | ||
| 4631 | (setq setmodes (basic-save-buffer-1)))) | ||
| 4632 | ;; Now we have saved the current buffer. Let's make sure | 4632 | ;; Now we have saved the current buffer. Let's make sure |
| 4633 | ;; that buffer-file-coding-system is fixed to what | 4633 | ;; that buffer-file-coding-system is fixed to what |
| 4634 | ;; actually used for saving by binding it locally. | 4634 | ;; actually used for saving by binding it locally. |