Search code examples
variablesemacseval

How to concat string in emacs elisp .dir-locals.el?


((c++-mode
    (rmsbolt-command . "/path/to/project/build_asm_for_rmsbolt.sh")

I want to pass a variable rmsbolt-temp-dir as a argument to the build_asm_for_rmsbolt.sh script, so idea is to concat the strings and rmsbolt-command should then look like:

"/path/to/project/build_asm_for_rmsbolt.sh /tmp/rmsbolt-123as"

So how do i concat the string variable to the command in .dir-locals.el?

I have tried:

((c++-mode
   (rmsbolt-command . ((eval . (concat "/path/to/project/build_asm_for_rmsbolt.sh" rmsbolt-temp-dir))))))

but this doesn't work. Elisp is a bit daunting, I am trying to learn as i speak.


Solution

  • In dir-local specs eval is a pseudo-variable, so you use that as the variable name, and then the associated value is the elisp that gets evaluated. Try something like this:

    ((c++-mode
      (rmsbolt-temp-dir . "/tmp/rmsbolt-123as")
      (eval . (setq-local rmsbolt-command
                          (concat "/path/to/project/build_asm_for_rmsbolt.sh "
                                  (shell-quote-argument rmsbolt-temp-dir))))))