Recompiling from a non-compilation buffer has security concerns.
The patch that I proposed above is intended only for
recompiling from a compilation buffer. It sets
`compilation-buffer-name-function' in the compilation buffer.
I think it behaves correctly inside the compilation buffer already? At
least it did when I tested.
Sorry, I didn't show my compilation function:
(setopt project-compilation-buffer-name-function
(lambda (name-of-mode)
(generate-new-buffer-name
(project-prefixed-buffer-name name-of-mode))))
Currently 'g' doesn't create a new compilation buffer, because
'compilation--default-buffer-name' just reuses the current buffer.