1

I have made buffer local changes to `process-environment' using the technique described in How can I get buffer-local environment variables via .dir-locals. I then call shell from that buffer. If I then view the environment variables in that shell using the following command, the buffer local changes are not included.

set | sort

I have used C-h v process-environment to confirm that the buffer local changes were made. However, if I added a variable in the buffer local process-environment it is not available in the shell.

For example, I set the environment variable P4ROOT in the buffer local process-environment. When I open a shell from that buffer, the P4ROOT environment variable is not set in the shell.

  • Tumbleweed? Really? Come on. Someone must have an answer to this. Well, I will eventually figure it out and answer my own question. – Ben Key Nov 7 '18 at 9:11
  • I have discovered the buffer-local-value function. I think this might be part of the solution, but I am still searching for the rest. – Ben Key Nov 14 '18 at 5:15
1

That's actually a bit tricky on account of how shell is written, so the following is quite implementation-specific and could break if things change upstream; however, give this a whirl:

(defadvice make-comint-in-buffer (before my-shell-dir-locals)
  (when (string= (ad-get-arg 0) "shell")
    (hack-dir-local-variables-non-file-buffer)))
(ad-activate 'make-comint-in-buffer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.