tweak(lib): open file after doom/copy-this-file

As mentioned in #6964, it's rare for anyone to want to copy a file
without opening the new file.

Close: #6964
This commit is contained in:
Henrik Lissner 2023-02-18 01:47:43 -05:00
parent c7c686cc26
commit 2c652259a5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -425,7 +425,7 @@ If FORCE-P, delete without confirmation."
;;;###autoload ;;;###autoload
(defun doom/copy-this-file (new-path &optional force-p) (defun doom/copy-this-file (new-path &optional force-p)
"Copy current buffer's file to NEW-PATH. "Copy current buffer's file to NEW-PATH then open NEW-PATH.
If FORCE-P, overwrite the destination file if it exists, without confirmation." If FORCE-P, overwrite the destination file if it exists, without confirmation."
(interactive (interactive
@ -437,6 +437,7 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
(new-path (expand-file-name new-path))) (new-path (expand-file-name new-path)))
(make-directory (file-name-directory new-path) 't) (make-directory (file-name-directory new-path) 't)
(copy-file old-path new-path (or force-p 1)) (copy-file old-path new-path (or force-p 1))
(find-file new-path)
(doom-files--update-refs old-path new-path) (doom-files--update-refs old-path new-path)
(message "File copied to %S" (abbreviate-file-name new-path)))) (message "File copied to %S" (abbreviate-file-name new-path))))