如何覆盖项目的 emacs-projectile 默认配置?

How to override emacs-projectile default configuration for project?

我尝试使用带有射弹的 emacs 来配置而不是构建 C++ CMake 项目。默认弹丸使用下一个配置:

(defconst projectile--cmake-manual-command-alist
  '((:configure-command . "cmake -S . -B build")
    (:compile-command . "cmake --build build")
    (:test-command . "cmake --build build --target test")))

如何为我的项目覆盖此设置(仅限我的项目)?假设我想做这样的事情:

(defconst projectile--cmake-manual-command-alist
  '((:configure-command . "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . -B .build")
    (:compile-command . "cmake --build .build")
    (:test-command . "cmake --build .build --target unit-tests")))

我搜索 throw documentation 但找不到一些简单的解决方案。我希望看到 .dir-locals.el 文件的修改有一些新变量。也许我做错了什么,我应该以不同的方式使用它?提前致谢。

你试过把这个 .dir-locals.el 放在你项目的根目录下吗?

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((c++-mode . ((projectile--cmake-manual-command-alist . ((:configure-command . "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . -B .build")
                                                    (:compile-command . "cmake --build .build")
                                                    (:test-command . "cmake --build .build --target unit-tests"))))))