Unfortunately this relied on trusting the source tree via the
safe-local-variable-directories otherwise users keep being prompted
that ".dir-locals.el contains values that may not be safe".

An alternative is for the user to add something like this to their
local emacs config:

  (defun my-return-source-if-in-qemu-tree()
    "Return the root of source when in QEMU code."
    (when-let ((src (expand-file-name (locate-dominating-file default-directory 
".git"))))
      (if (file-exists-p (concat src "/qemu-options.hx"))
          src)))

  (defun my-set-qemu-python-path()
    "Set local python environment for QEMU."
    (when-let ((root (my-return-source-if-in-qemu-tree)))
      (setq-local process-environment (copy-sequence process-environment))
      (setenv "PYTHONPATH" (concat (expand-file-name "python" root) ":"
                                   (expand-file-name "tests/functional" 
root)))))

  (use-package python
    :hook ((python-mode python-ts-mode) . my-set-qemu-python-path))

This reverts commit 3112269be3ac92343a5f0e5d9eae919edd176a35.

Signed-off-by: Alex Bennée <[email protected]>
---
 .dir-locals.el | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 51871619422..3ac0cfc6f0d 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,8 +1,2 @@
 ((c-mode . ((c-file-style . "stroustrup")
-           (indent-tabs-mode . nil)))
- (python-mode .
-              ((eval . (when-let* ((root (locate-dominating-file 
default-directory ".dir-locals.el")))
-                         (setq-local process-environment (copy-sequence 
process-environment))
-                         (setenv "PYTHONPATH"
-                                 (concat (expand-file-name "python" root) ":"
-                                         (expand-file-name "tests/functional" 
root))))))))
+           (indent-tabs-mode . nil))))
-- 
2.47.3


Reply via email to