这次很难生产MWE。。。
我很久以前就意识到,当R在ESS会话中使用时,它不再保存Rhistory。我在Rprofile中添加了自定义行

if (interactive()) {
  .Last <- function() try(savehistory())
}

但这只在命令行中启动R时有效。
使用ESS时,我会收到消息:
Save workspace image? [y/n/c]: y
Error in .External2(C_savehistory, file) : no history available to save

不幸的是我不记得这一切是什么时候开始的。。。
有线索吗?
我正在使用:
> version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          6.1
year           2019
month          07
day            05
svn rev        76782
language       R
version.string R version 3.6.1 (2019-07-05)
nickname       Action of the Toes


GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21)


ESS version 18.10.2

我不得不承认这有点烦人。。。
谢谢大家,
亚历克斯
----2006年11月更新----
我添加了一个.Renviron和一个.Rprofile,就像你的一样,我也在.emacs中设置了ess history文件ess history目录,但是我仍然得到同样的错误。。。这发生在两台不同的机器上,有着相同的“设置”(操作系统,版本,来源…)…对我来说,这听起来像一个bug。。。

最佳答案

ESS使用comint接口作为后端来管理劣质进程,该进程还处理读/写历史文件。我不认为最近有什么变化。
因此,您可以使用注释中提到的变量ess-history-fileess-history-directory来配置历史文件位置,这些变量会间接地更新相邻缓冲区中的变量,例如comint-input-rile-file-name
要在R启动时使用相同的历史记录,而不是emacs,我在.Renviron/.Rprofile文件中使用如下内容
雷维龙

R_HISTFILE=$HOME/.Rhistory

.r轮廓
.Last <- function() {
    if (interactive()) {
        hist_file <- Sys.getenv("R_HISTFILE")
        if (hist_file == "")
            hist_file <- "~/.Rhistory"
    }
}

10-07 19:29
查看更多