Fix {copy,move}-this-file commands when file doesn't exist yet
This commit is contained in:
parent
f058505306
commit
f3f8172579
1 changed files with 5 additions and 3 deletions
|
@ -56,9 +56,10 @@
|
||||||
(not force-p)
|
(not force-p)
|
||||||
(not (y-or-n-p (format "File already exists at %s, overwrite?" short-new-name))))
|
(not (y-or-n-p (format "File already exists at %s, overwrite?" short-new-name))))
|
||||||
(throw 'status 'aborted))
|
(throw 'status 'aborted))
|
||||||
(t
|
((file-exists-p old-path)
|
||||||
(copy-file old-path new-path t)
|
(copy-file old-path new-path t)
|
||||||
short-new-name))))
|
short-new-name)
|
||||||
|
(short-new-name))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/delete-this-file (&optional path force-p)
|
(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))
|
(let ((old-path (buffer-file-name))
|
||||||
(new-path (expand-file-name new-path)))
|
(new-path (expand-file-name new-path)))
|
||||||
(when-let* ((dest (doom--copy-file old-path new-path force-p)))
|
(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)
|
(kill-this-buffer)
|
||||||
(find-file new-path)
|
(find-file new-path)
|
||||||
(doom--forget-file old-path new-path)
|
(doom--forget-file old-path new-path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue