summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 148f47cbc97..e93181499b7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5764,9 +5764,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.
- (let ((dir (file-name-directory
+ (let ((file (buffer-file-name))
+ (dir (file-name-directory
(expand-file-name buffer-file-name))))
- (unless (file-exists-p dir)
+ ;; Some systems have directories (like /content on
+ ;; Android) in which files can exist without a
+ ;; corresponding parent directory.
+ (unless (or (file-exists-p file)
+ (file-exists-p dir))
(if (y-or-n-p
(format-message
"Directory `%s' does not exist; create? " dir))