;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; http://blog.tuxicity.se/elisp/emacs/2010/03/26/rename-file-and-buffer-in-emacs.htm
+
+(defun rename-file-and-buffer ()
+ "Renames current buffer and file it is visiting."
+ (interactive)
+ (let ((name (buffer-name))
+ (filename (buffer-file-name)))
+ (if (not (and filename (file-exists-p filename)))
+ (message "Buffer '%s' is not visiting a file!" name)
+ (let ((new-name (read-file-name "New name: " filename)))
+ (cond ((get-buffer new-name)
+ (message "A buffer named '%s' already exists!" new-name))
+ (t
+ (rename-file name new-name 1)
+ (rename-buffer new-name)
+ (set-visited-file-name new-name)
+ (set-buffer-modified-p nil)))))))
+
+(global-set-key (kbd "C-c r") 'rename-file-and-buffer)
+
(defun ff/non-existing-filename (dir prefix suffix)
"Returns a filename of the form DIR/PREFIX[.n].SUFFIX whose file does
not exist"