fix: doom/move-this-file when directory is the target

* doom/move-this-file now supports moving directly into a directory
* applied requested changes

Close #4861
This commit is contained in:
NightMachinary 2021-08-01 23:43:52 +04:30 committed by GitHub
parent 65950f3e91
commit a6f365bb3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -282,6 +282,8 @@ If FORCE-P, overwrite the destination file if it exists, without confirmation."
(user-error "Buffer is not visiting any file")) (user-error "Buffer is not visiting any file"))
(let ((old-path (buffer-file-name (buffer-base-buffer))) (let ((old-path (buffer-file-name (buffer-base-buffer)))
(new-path (expand-file-name new-path))) (new-path (expand-file-name new-path)))
(when (directory-name-p new-path)
(setq new-path (concat new-path (file-name-nondirectory old-path))))
(make-directory (file-name-directory new-path) 't) (make-directory (file-name-directory new-path) 't)
(rename-file old-path new-path (or force-p 1)) (rename-file old-path new-path (or force-p 1))
(set-visited-file-name new-path t t) (set-visited-file-name new-path t t)