Make set-visited-file-name reload local variables if needed.
authorGlenn Morris <rgm@gnu.org>
Thu, 27 Oct 2011 06:38:32 +0000 (23:38 -0700)
committerGlenn Morris <rgm@gnu.org>
Thu, 27 Oct 2011 06:38:32 +0000 (23:38 -0700)
* lisp/files.el (set-visited-file-name):
If the major-mode changed, reload the local variables.

Fixes: debbugs:9796

lisp/ChangeLog
lisp/files.el

index f4a0cee..cbfc662 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-27  Glenn Morris  <rgm@gnu.org>
+
+       * files.el (set-visited-file-name): If the major-mode changed,
+       reload the local variables.  (Bug#9796)
+
 2011-10-27  Chong Yidong  <cyd@gnu.org>
 
        * subr.el (change-major-mode-after-body-hook): New hook.
index 3ed9bd5..40e2df1 100644 (file)
@@ -3682,7 +3682,11 @@ the old visited file has been renamed to the new name FILENAME."
          (get major-mode 'mode-class)
          ;; Don't change the mode if the local variable list specifies it.
          (hack-local-variables t)
-         (set-auto-mode t))
+         ;; TODO consider making normal-mode handle this case.
+         (let ((old major-mode))
+           (set-auto-mode t)
+           (or (eq old major-mode)
+               (hack-local-variables))))
     (error nil)))
 
 (defun write-file (filename &optional confirm)