在我的 .bashrc 文件中,我有这样一行代码:
如果我在bash中加载R,我可以使用
如果我在Emacs中打开R(M-x R),SETTINGS是空的:
我尝试过以下方法:
export SETTINGS=/home/user/settings.xml
如果我在bash中加载R,我可以使用
Sys.getenv
函数访问此变量:Sys.getenv("SETTINGS")
"/home/user/settings.xml"
如果我在Emacs中打开R(M-x R),SETTINGS是空的:
Sys.getenv("SETTINGS")
""
我尝试过以下方法:
adding the following to .emacs, based on How do I make Emacs recognize bash environment variables for compilation?
;; get environment vars from .bashrc (let ((path (shell-command-to-string ". ~/.bashrc; echo -n $SETTINGS"))) (setenv "SETTINGS" path))
opening up bash in emacs using
M-x term
echo $SETTINGS # works R Sys.getenv("SETTINGS") #works
If I open emacs from the terminal, the SETTINGS variable is available as expected. Opening emacs from the Applications menu (with either the command
/usr/bin/emacs23 %F
oremacs
) does not work.comparing output from
session("env")
when loading R in bash vs emacs, but nothing stands out other than (bash = <, emacs = >):> INSIDE_EMACS=23.3.1,comint 6d5 < SETTINGS=/home/user/settings.xml 9c8 < SHLVL=1 > SHLVL=0 14a14 > PAGER=cat 16d15 < PAGER=/usr/bin/pager 19d17 < COLORTERM=gnome-terminal 25c23 < WINDOWID=14680069 > DESKTOP_AUTOSTART_ID=1020ce948b944a88113395253627645060000001863000 < TERM=xterm > TERM=dumb
我可以在emacs-ess中从R中访问SETTINGS吗?
- 或者,我可以将设置导出到我可以访问的某个地方吗?
/usr/bin/emacs23 %F
打开无效。 - Abe