magthe0 · 2022-04-03 13:23
I put the following in `.dir-locals.el` in a Go project of mine:
```
((nil . ((projectile-project-compilation-cmd . "go test .")))
(go-mode . ((compile-command . "go build -v "))))
```
with the intention of being able to _both_ compile the project (running its tests) and compile a single file.
The commands are working fine, but compiling the project (running its tests) affects the value of `compile-command`, it sets it to the same value as `projectile-project-compilation-cmd`.
Is there a setting to prevent that behaviour, as I really want to be able to do both?
crawsphi · 2022-04-03 18:10
Yeah, this is a mild annoyance with funneling everything through `compile`. Without writing some Elisp, I think the best you can do is use history: `M-p` in the compile prompt will move back to older entries.
If you do want to write a wrapper command, you can make `compile-command` buffer-local for the files you want to compile on their own. If you mean that you want to run both of these on the same file, then I think you will need two Elisp commands.
magthe0 · 2022-04-03 20:17
Yes, it is a bit of nuisance. Very nice that you pointed out the option of using functions. As I'm using Spacemacs there already is a function I can use for running the tests, and I can leave the `compile-command` as it is. Then I end up with the following:
```
((nil . ((projectile-project-compilation-cmd . spacemacs/go-run-package-tests)))
(go-mode . ((compile-command . "go build -v "))))
```