*** The non-nil value of 'dired-dwim-target' uses one of the most recently
visited windows with a Dired buffer instead of the next window.
+*** When the new user option 'dired-vc-rename-file' is non-nil,
+Dired performs file renaming using underlying version control system.
+
** Find-Dired
*** New user option 'find-dired-refine-function'.
dired-create-files-failures)
(dired-log "Can't set date on %s:\n%s\n" from err))))))
+(defcustom dired-vc-rename-file nil
+ "Whether Dired should register file renaming in underlying vc system.
+If nil, use default `rename-file'.
+If non-nil and the renamed files are under version control,
+rename them using `vc-rename-file'."
+ :type '(choice (const :tag "Use rename-file" nil)
+ (const :tag "Use vc-rename-file" t))
+ :group 'dired
+ :version "27.1")
+
;;;###autoload
(defun dired-rename-file (file newname ok-if-already-exists)
(dired-handle-overwrite newname)
(dired-maybe-create-dirs (file-name-directory newname))
- (rename-file file newname ok-if-already-exists) ; error is caught in -create-files
+ (if (and dired-vc-rename-file
+ (vc-backend file)
+ (ignore-errors (vc-responsible-backend newname)))
+ (vc-rename-file file newname)
+ ;; error is caught in -create-files
+ (rename-file file newname ok-if-already-exists))
;; Silently rename the visited file of any buffer visiting this file.
(and (get-file-buffer file)
(with-current-buffer (get-file-buffer file)
(when (file-exists-p new)
(error "New file already exists"))
(let ((state (vc-state old)))
- (unless (memq state '(up-to-date edited))
+ (unless (memq state '(up-to-date edited added))
(error "Please %s files before moving them"
(if (stringp state) "check in" "update"))))
(vc-call rename-file old new)
(vc-file-clearprops old)
+ (vc-file-clearprops new)
;; Move the actual file (unless the backend did it already)
(when (file-exists-p old) (rename-file old new))
;; ?? Renaming a file might change its contents due to keyword expansion.