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.

Benilda Key
  • 159
  • 8
  • Tumbleweed? Really? Come on. Someone must have an answer to this. Well, I will eventually figure it out and answer my own question. – Benilda Key Nov 07 '18 at 09: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. – Benilda Key Nov 14 '18 at 05:15

1 Answers1

2

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)
phils
  • 48,657
  • 3
  • 76
  • 115