summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el18
1 files changed, 9 insertions, 9 deletions
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
(not (file-exists-p buffer-file-name))))
(let ((recent-save (recent-auto-save-p))
setmodes)
- (if buffer-file-name
- (let ((dir (file-name-directory
- (expand-file-name buffer-file-name))))
- (unless (file-exists-p dir)
- (if (y-or-n-p
- (format "Directory `%s' does not exist; create? " dir))
- (make-directory dir t)
- (error "Canceled"))))
;; If buffer has no file name, ask user for one.
+ (or buffer-file-name
(let ((filename
(expand-file-name
(read-file-name "File to save in: "
@@ -4628,7 +4621,14 @@ Before and after saving the buffer, this function runs
(run-hook-with-args-until-success 'write-file-functions)
;; If a hook returned t, file is already "written".
;; Otherwise, write it the usual way now.
- (setq setmodes (basic-save-buffer-1)))
+ (let ((dir (file-name-directory
+ (expand-file-name buffer-file-name))))
+ (unless (file-exists-p dir)
+ (if (y-or-n-p
+ (format "Directory `%s' does not exist; create? " dir))
+ (make-directory dir t)
+ (error "Canceled")))
+ (setq setmodes (basic-save-buffer-1))))
;; Now we have saved the current buffer. Let's make sure
;; that buffer-file-coding-system is fixed to what
;; actually used for saving by binding it locally.