Make prelude-rename-file-and-buffer vc aware

This commit is contained in:
Bozhidar Batsov 2013-05-04 10:28:04 +03:00
parent 2866052b6c
commit f3fffbffce

View file

@ -181,19 +181,17 @@ there's a region, all lines that region covers will be duplicated."
(setq end (point))))
(goto-char (+ origin (* (length region) arg) arg)))))
;; TODO doesn't work with uniquify
(defun prelude-rename-file-and-buffer ()
"Renames current buffer and file it is visiting."
(interactive)
(let ((name (buffer-name))
(filename (buffer-file-name)))
(let ((filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(message "Buffer '%s' is not visiting a file!" name)
(message "Buffer is not visiting a file!")
(let ((new-name (read-file-name "New name: " filename)))
(cond ((get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name))
(cond
((vc-backend filename) (vc-rename-file filename new-name))
(t
(rename-file name new-name 1)
(rename-file filename new-name t)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)))))))