summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--emacs/init.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/emacs/init.el b/emacs/init.el
index c1407ac..41f9821 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."