el/dot-emacs.el: Advise `rename-file' to rename buffers at the same time.
[profile] / el / dot-emacs.el
index 0c402be..23b2c97 100644 (file)
@@ -588,6 +588,15 @@ Even if an existing window in some random frame looks tempting."
 Pretend they don't exist.  They might be on other display devices."
   (ad-set-arg 2 nil))
 
+;; Rename buffers along with files.
+
+(defadvice rename-file (after mdw-rename-buffers (from to &optional forcep)
+                       compile activate)
+  (let ((buffer (get-file-buffer from)))
+    (when buffer
+      (with-current-buffer buffer
+       (set-visited-file-name to nil t)))))
+
 ;;;--------------------------------------------------------------------------
 ;;; Improved compilation machinery.