Subject: 31.0.50 master; .dir-locals.el vars does not work with changing major mode
From: Yikai Zhao <[email-masked]>
To: [email-masked]
Date: Thu, 19 Dec 2024 15:53:58 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

How to reproduce:

With following content in /tmp/test/.dir-locals.el:

((nil . ((my/test . "test")))
 (c-mode . ((eval . (when (eq major-mode 'c-mode)
                      (c++-mode))))))
;; I use this code because I want my projects' .h files always opened
in c++ mode

Then open a new file test.c in the folder.

Expected behavior: my/test variable is set.
Actual behavior: my/test variable is not set.

Emacs 29 and 30 does give me the expected result.