使用射弹在.dir-locals中设置flycheck-clang-include-path

时间:2017-06-04 19:00:29

标签: emacs elisp projectile flycheck

尝试设置flycheck-clang-include-path而不需要包含项目的完整路径包括使用projectile的目录,但是我收到错误......所以这有效:

((nil . (
     (company-clang-arguments . (
                     "/home/user/Downloads/project/headers"
                     "/home/user/Downloads/project/source/mon"
                     ))
         (flycheck-clang-include-path . (
                     "/home/user/Downloads/project/headers"
                     "/home/user/Downloads/project/source/mon"
                     ))
     )))

但这不是:

((nil . (
     (company-clang-arguments . (
                     (concat "-I" (projectile-project-root) "headers")
                     (concat "-I" (projectile-project-root) "source/mon")
                     ))
         (flycheck-clang-include-path . (
                     (concat (projectile-project-root) "headers")
                     (concat (projectile-project-root) "source/mon")
                     ))
     )))

报告的错误:

flycheck-substitute-argument: Value ((concat (projectile-project-root) "headers")) of flycheck-clang-include-path for option "-I" is not a list of strings

1 个答案:

答案 0 :(得分:1)

一种可能性是使用eval评估dir-locals中引用的表单。这可能被认为是不安全的,因为任何事情都可以用这种形式进行评估。

((nil 
  (eval . (let ((root (projectile-project-root)))
            (setq-local company-clang-arguments
                        (list (concat "-I" root "headers")
                              (concat "-I" root "source/mon")))
            (setq-local flycheck-clang-include-path
                        (list (concat root "headers")
                              (concat root "source/mon")))))))