Make prelude-rename-file-and-buffer vc aware
This commit is contained in:
parent
2866052b6c
commit
f3fffbffce
1 changed files with 9 additions and 11 deletions
|
@ -181,22 +181,20 @@ 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)))))))
|
||||||
|
|
||||||
(defun prelude-delete-file-and-buffer ()
|
(defun prelude-delete-file-and-buffer ()
|
||||||
"Kill the current buffer and deletes the file it is visiting."
|
"Kill the current buffer and deletes the file it is visiting."
|
||||||
|
|
Loading…
Reference in a new issue