2

I have a plugin system setup that will (at compile time) search through all the plugins in the plugins directory.

My problem is that I'm trying to allow for flycheck to add these plugins' headers to the include paths.

I have the problem that I can't figure out how to make the expression actually evaluate to its value. (The expression is treated as a value rather than being evaluated)

((c++-mode . ((flycheck-clang-include-path . (split-string (substring
                                                            (shell-command-to-string
                                                             (concat "echo src;"
                                                                     "cd /home/czipperz/vick &&"
                                                                     "[ \"$(ls plugins)\" ] &&"
                                                                     "[ \"$(find plugins -name src -type d)\" ] &&"
                                                                     "   find plugins -name src -type d")) 0 -1)
                                                           "\n+")))))

When I open a file I get an error: Error while checking syntax automatically: (split-string (substring ...) "\n+") of flycheck-clang-include-path for option "-I" is not a list of strings.

Czipperz
  • 3,268
  • 2
  • 18
  • 25

2 Answers2

2

The eval pseudo-variable facilitates evaluation in local-variable configurations.

e.g.:

If you are setting variables in an eval form, take care that you are setting buffer-local values (as a general rule, just use setq-local instead of setq in these cases).

Community
  • 1
  • 1
phils
  • 71,335
  • 11
  • 153
  • 198
0

The expression is treated as a value rather than being evaluated

This is exactly the cause. The content of the .dir-locals.el file is not elisp to be evaluated but rather a list to be read as data.

As an alternative, consider adding a call to dir-locals-set-class-variables in your init file. This function takes a symbol to use as a class name and a list of variables (which you can compute in any fashion you want). Then use dir-locals-set-directory-class to set a particular directory name (given as a path) to the new class you've created. The Emacs manual includes an example; M-: (info "(emacs)Directory Variables") will take you to it.

db48x
  • 3,108
  • 24
  • 16