@@ -745,23 +745,26 @@ RECURSIVE is non-nil."
745
745
(delete-directory file-or-directory recursive trash)
746
746
(delete-file file-or-directory trash)))
747
747
748
- (defun +move-this-file (new-path &optional force-p)
749
- " Move current buffer's file to NEW-PATH.
748
+ (if (fboundp 'rename-visited-file )
749
+ (defalias '+move-this-file #'rename-visited-file )
750
+
751
+ (defun +move-this-file (new-path &optional force-p)
752
+ " Move current buffer's file to NEW-PATH.
750
753
751
754
If FORCE-P, overwrite the destination file if it exists, without confirmation."
752
- (interactive
753
- (list (read-file-name " Move file to: " )
754
- current-prefix-arg))
755
- (unless (and buffer-file-name (file-exists-p buffer-file-name))
756
- (user-error " Buffer is not visiting any file" ))
757
- (let ((old-path (buffer-file-name (buffer-base-buffer )))
758
- (new-path (expand-file-name new-path)))
759
- (when (directory-name-p new-path)
760
- (setq new-path (expand-file-name (file-name-nondirectory old-path) new-path)))
761
- (make-directory (file-name-directory new-path) t )
762
- (rename-file old-path new-path (or force-p 1 ))
763
- (set-visited-file-name new-path t t )
764
- (message " File moved to %S " (abbreviate-file-name new-path))))
755
+ (interactive
756
+ (list (read-file-name " Move file to: " )
757
+ current-prefix-arg))
758
+ (unless (and buffer-file-name (file-exists-p buffer-file-name))
759
+ (user-error " Buffer is not visiting any file" ))
760
+ (let ((old-path (buffer-file-name (buffer-base-buffer )))
761
+ (new-path (expand-file-name new-path)))
762
+ (when (directory-name-p new-path)
763
+ (setq new-path (expand-file-name (file-name-nondirectory old-path) new-path)))
764
+ (make-directory (file-name-directory new-path) t )
765
+ (rename-file old-path new-path (or force-p 1 ))
766
+ (set-visited-file-name new-path t t )
767
+ (message " File moved to %S " (abbreviate-file-name new-path) ))))
765
768
766
769
(autoload 'tramp-make-tramp-file-name " tramp" )
767
770
(defvar tramp-root-id-string )
0 commit comments