Skip to content

Instantly share code, notes, and snippets.

@rubyist
Created July 7, 2010 19:22
Show Gist options
  • Save rubyist/467134 to your computer and use it in GitHub Desktop.
Save rubyist/467134 to your computer and use it in GitHub Desktop.
(defun rename-file-and-buffer (new-name)
(interactive "sNew Name: ")
(write-file (buffer-file-name))
(setq new-file-path (concat (file-name-directory (buffer-file-name)) new-name))
(if vc-mode
(vc-rename-file (buffer-file-name) new-file-path)
(rename-file (buffer-file-name) new-file-path))
(set-visited-file-name new-file-path nil 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment