关于 shell:Emacs 外部进程调用期间的临时修改环境

Temporary Modified Environment during External Process Call from Emacs

在使用 shell-comandstart-process 时,是否有一种方便且实用(类似于 with-...)的方式来临时修改环境变量?

提前致谢,


进程环境是一个
子进程要继承的覆盖环境变量列表。

1
2
(let ((process-environment (cons"FOO=BAR" process-environment)))
  (shell-command-to-string"echo $FOO"))

->

1
BAR

server-with-environment 看起来很有前途。

server-with-environment is a Lisp macro in `server.el'.

(server-with-environment ENV VARS &rest BODY)

Evaluate BODY with environment variables VARS set to those in ENV.
The environment variables are then restored to their previous values.

VARS should be a list of strings.
ENV should be in the same format as `process-environment'.