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)))) (setq end (point))))
(goto-char (+ origin (* (length region) arg) arg))))) (goto-char (+ origin (* (length region) arg) arg)))))
;; TODO doesn't work with uniquify
(defun prelude-rename-file-and-buffer () (defun prelude-rename-file-and-buffer ()
"Renames current buffer and file it is visiting." "Renames current buffer and file it is visiting."
(interactive) (interactive)
(let ((name (buffer-name)) (let ((filename (buffer-file-name)))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename))) (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))) (let ((new-name (read-file-name "New name: " filename)))
(cond ((get-buffer new-name) (cond
(message "A buffer named '%s' already exists!" new-name)) ((vc-backend filename) (vc-rename-file filename new-name))
(t (t
(rename-file name new-name 1) (rename-file filename new-name t)
(rename-buffer new-name) (rename-buffer new-name)
(set-visited-file-name new-name) (set-visited-file-name new-name)
(set-buffer-modified-p nil))))))) (set-buffer-modified-p nil)))))))