emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dired-vc-rename (was: git show)


From: Juri Linkov
Subject: dired-vc-rename (was: git show)
Date: Sat, 02 Nov 2019 20:48:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> Ie. history is not tracked across moves/renames.

BTW, I wonder how in Dired everyone moves/renames
files in a directory under version control?

When using simply R in Dired to move vc files,
this messes everything up: vc-dired thinks that
the file with an old name is removed,
and a new file is created unregistered.

I'm using such patch, and it works well.
Should this be installed?

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index b1521ecf01..13a2d8cd6b 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1635,11 +1635,24 @@ dired-copy-file-recursive
               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.
+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))
+      (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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]