summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2013-05-04 09:12:04 +0100
committerAlan Pearce2013-05-04 09:12:04 +0100
commit7715d133347319dc8585601ac783faf2ee566f9d (patch)
tree9f00abd333501e21642a460123a2d2a2aecf5cbc
parent2e008b02c690b0e1c6cfb815218cb09c02c81da3 (diff)
downloadnixfiles-7715d133347319dc8585601ac783faf2ee566f9d.tar.lz
nixfiles-7715d133347319dc8585601ac783faf2ee566f9d.tar.zst
nixfiles-7715d133347319dc8585601ac783faf2ee566f9d.zip
Emacs: rename-current-buffer-file should use vc-rename-file when appropriate
-rw-r--r--emacs/init.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/emacs/init.el b/emacs/init.el
index c1407ace..41f98214 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -354,12 +354,14 @@
       (let ((new-name (read-file-name "New name: " filename)))
         (if (get-buffer new-name)
             (error "A buffer named '%s' already exists!" new-name)
-          (rename-file filename new-name 1)
-          (rename-buffer new-name)
-          (set-visited-file-name new-name)
-          (set-buffer-modified-p nil)
-          (message "File '%s' successfully renamed to '%s'"
-                   name (file-name-nondirectory new-name)))))))
+          (cond
+           ((vc-backend filename) (vc-rename-file filename new-name))
+           (t (rename-file filename new-name t)
+              (rename-buffer new-name)
+              (set-visited-file-name new-name)
+              (set-buffer-modified-p nil)
+              (message "File '%s' successfully renamed to '%s'"
+                       name (file-name-nondirectory new-name)))))))))
 
 (defun delete-current-buffer-file ()
   "Removes file connected to current buffer and kills buffer."