diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f4a0ceecf93..cbfc662da52 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-10-27 Glenn Morris + + * files.el (set-visited-file-name): If the major-mode changed, + reload the local variables. (Bug#9796) + 2011-10-27 Chong Yidong * subr.el (change-major-mode-after-body-hook): New hook. diff --git a/lisp/files.el b/lisp/files.el index 3ed9bd5a272..40e2df14c1b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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)