Subject: project-mode-line-format restarts ispell process on every keystroke

From: Juri Linkov <[email-masked]>
Date: Tue, 12 Mar 2024 09:53:37 +0200

[related to bug#69703]

When .dir-locals.el contains:

  ((nil . ((mode . flyspell))))

here is a backtrace that illustrates the problem:

    flyspell-mode()
    set-auto-mode-0(flyspell-mode t)
    hack-one-local-variable(mode flyspell)
    hack-local-variables-apply()
    hack-dir-local-variables-non-file-buffer()
    project--value-in-dir(project-vc-name "/tmp/test/")
    project-name((vc Git "/tmp/test/"))
    project-mode-line-format()
    eval((project-mode-line-format) t)
    redisplay_internal\ \(C\ function\)()

This can be fixed by not allowing to run any mode
while reading a project name from dir-locals.

So here is a patch that fixes it:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 9622b1b6768..8578af1cde4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -808,8 +808,8 @@ project--value-in-dir
   (with-temp-buffer
     (setq default-directory dir)
     (let ((enable-local-variables :all))
-      (hack-dir-local-variables-non-file-buffer))
-    (symbol-value var)))
+      (hack-dir-local-variables))
+    (alist-get var file-local-variables-alist)))
 
 (cl-defmethod project-buffers ((project (head vc)))
   (let* ((root (expand-file-name (file-name-as-directory (project-root project))))