summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el21
1 files changed, 11 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 1e1ec6127de..b953961aa18 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6127,16 +6127,17 @@ recent files are first."
(let* ((filename (file-name-sans-versions
(make-backup-file-name (expand-file-name filename))))
(dir (file-name-directory filename)))
- (sort
- (seq-filter
- (lambda (candidate)
- (and (backup-file-name-p candidate)
- (string= (file-name-sans-versions candidate) filename)))
- (mapcar
- (lambda (file)
- (concat dir file))
- (file-name-all-completions (file-name-nondirectory filename) dir)))
- #'file-newer-than-file-p)))
+ (when (file-directory-p dir)
+ (sort
+ (seq-filter
+ (lambda (candidate)
+ (and (backup-file-name-p candidate)
+ (string= (file-name-sans-versions candidate) filename)))
+ (mapcar
+ (lambda (file)
+ (concat dir file))
+ (file-name-all-completions (file-name-nondirectory filename) dir)))
+ #'file-newer-than-file-p))))
(defun rename-uniquely ()
"Rename current buffer to a similar name not already taken.