summaryrefslogtreecommitdiff
path: root/lisp/dired-aux.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2019-11-07 01:14:58 +0200
committerJuri Linkov <juri@linkov.net>2019-11-07 01:14:58 +0200
commitdeb61da7a27698ddc0b95ba92d18c20f533bb802 (patch)
tree2309fc8637f80d5ba4607f8a5527555e860248d0 /lisp/dired-aux.el
parent528485d0172f00e5f0c8ea548013a49964be501b (diff)
downloademacs-deb61da7a27698ddc0b95ba92d18c20f533bb802.tar.gz
emacs-deb61da7a27698ddc0b95ba92d18c20f533bb802.tar.bz2
emacs-deb61da7a27698ddc0b95ba92d18c20f533bb802.zip
* lisp/dired-aux.el (dired-vc-rename-file): New defcustom.
(dired-rename-file): Call vc-rename-file when dired-vc-rename-file is non-nil. * lisp/vc/vc.el (vc-rename-file): Allow renaming added files. Call vc-file-clearprops on new file too for the case when old and new files were renamed to each other back and forth. https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg00069.html
Diffstat (limited to 'lisp/dired-aux.el')
-rw-r--r--lisp/dired-aux.el17
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index b1521ecf018..722d036e3fc 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1635,11 +1635,26 @@ If `ask', ask for user confirmation."
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)