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
1 files changed, 8 insertions(+), 6 deletions(-)
jump to
M emacs/init.el → emacs/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."