From f3f817257920d8e4b1cb541e9a72d4487328fea6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 20 May 2018 15:17:59 +0200 Subject: [PATCH] Fix {copy,move}-this-file commands when file doesn't exist yet --- core/autoload/files.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/autoload/files.el b/core/autoload/files.el index c2bf906b3..e77df3ec0 100644 --- a/core/autoload/files.el +++ b/core/autoload/files.el @@ -56,9 +56,10 @@ (not force-p) (not (y-or-n-p (format "File already exists at %s, overwrite?" short-new-name)))) (throw 'status 'aborted)) - (t + ((file-exists-p old-path) (copy-file old-path new-path t) - short-new-name)))) + short-new-name) + (short-new-name)))) ;;;###autoload (defun doom/delete-this-file (&optional path force-p) @@ -107,7 +108,8 @@ file if it exists, without confirmation." (let ((old-path (buffer-file-name)) (new-path (expand-file-name new-path))) (when-let* ((dest (doom--copy-file old-path new-path force-p))) - (delete-file old-path) + (when (file-exists-p old-path) + (delete-file old-path)) (kill-this-buffer) (find-file new-path) (doom--forget-file old-path new-path)