all repos — archive/dotfiles @ 7715d133347319dc8585601ac783faf2ee566f9d

Superseded by nixfiles

Emacs: rename-current-buffer-file should use vc-rename-file when appropriate
Alan Pearce alan@alanpearce.co.uk
Sat, 04 May 2013 09:12:04 +0100
commit

7715d133347319dc8585601ac783faf2ee566f9d

parent

2e008b02c690b0e1c6cfb815218cb09c02c81da3

1 files changed, 8 insertions(+), 6 deletions(-)

jump to
M emacs/init.elemacs/init.el
@@ -354,12 +354,14 @@ (error "Buffer '%s' is not visiting a file!" name)       (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."