Temporary Modified Environment during External Process Call from Emacs

风格不统一 提交于 2019-12-04 14:55:05

server-with-environment looks promising.

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'.

process-environment is a List of overridden environment variables for subprocesses to inherit.

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

->

BAR
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!