Subject: bug#15577: 24.3; dir-local variables not applied when switching major-mode

From: yary <[email-masked]>
Date: Sat, 19 Oct 2013 15:08:17 -0400

On Fri, Oct 18, 2013 at 9:18 PM, Stefan Monnier
<[email-masked]> wrote:
>> For sub-issue #1 "dir-locals not being applied in the new mode,"
>> divide the responsibility for setting file-locals and dir-locals
>> between `normal-mode find-file=t' and `define-derived-mode'. Just have
>> `define-derived-mode' call
>> `(hack-dir-local-variables)(hack-local-variables-apply)' unless it is
>> being called as a result of `normal-mode t'. There's no change needed
>> for the normal-mode function or anything it calls, except perhaps
>> setting something that the define-derived-mode macro can check.
>
> Yes, as mentioned earlier, a possible fix is to move the file-local and
> dir-local setup code from normal-mode to after-change-major-mode-hook.

Moving dir-local setup code to after-change-major-mode-hook would be a
simple fix for issue #1. File-local (as it is now) in
after-change-major-mode-hook would cause some problems eg. if a
file-local sets the mode!

I'm opening a new bug for handling file-locals after
major-mode-change, it's different enough to warrant its own discussion
(and will also answer your questions about what I meant there), The
initial report here was about dir-locals, which has a solution
independent from the other buffer-local issues; let's just keep this
bug#15577 about re-applying dir locals after a mode change.