Fix {copy,move}-this-file commands when file doesn't exist yet

This commit is contained in:
Henrik Lissner 2018-05-20 15:17:59 +02:00
parent f058505306
commit f3f8172579
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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)