From 51bc5f8b7385d8e632add4f70ca091ebe7a32799 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 26 Oct 2011 23:38:32 -0700 Subject: [PATCH] Make set-visited-file-name reload local variables if needed. * lisp/files.el (set-visited-file-name): If the major-mode changed, reload the local variables. Fixes: debbugs:9796 --- lisp/ChangeLog | 5 +++++ lisp/files.el | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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) -- 2.39.5