Is there a way to make buffer-local overrides to exec-path
(whose value is normally initialized with the PATH
environment variable)?
I tried (make-variable-buffer-local 'exec-path)
and local overrides seem to work fine after that, but are there any harmful side effects? In any case, this is non-standard, so is there an officially blessed way to do it?
One reason for a buffer-local path would be to use project-specific versions of tools in Node.js and other projects.
setq-local
would have even less impact since it really only effects the value ofexec-path
in the current buffer. The other buffers still share the same value. Withmake-variable-buffer-local
the variable becomes buffer local in all buffers. That could break things. Especially if you do something like that in the early initialization phase. For an instance a package could add the directory path of an external program via(setq exec-path (cons ... exec-path))
even if that is not advisable. That path would only be added in the buffer whereload-package
run.let
-bind the value you wanted around the call to the function which needed it.