【发布时间】:2021-04-12 16:57:14
【问题描述】:
我使用 Emacs ESS 作为我的 R 编程环境
OS: Ubuntu 20.04 (x86_46)
Emacs version: 27.1
我的 init 文件中有以下 polymode 配置(我从 MELPA 安装了三个包:polymode、poly-markdown 和 poly-r)
; ==========================
; Polymode for R markdown
; ==========================
; M-x package-install [RET] polymode [RET]
; M-x package-install [RET] poly-markdown [RET]
; M-x package-install [RET] poly-R [RET]
;
(use-package polymode
:diminish (poly-org-mode
poly-markdown-mode
poly-noweb+r-mode
poly-noweb+r-mode
poly-markdown+r-mode
poly-rapport-mode
poly-html+r-mode
poly-brew+r-mode
poly-r+c++-mode
poly-c++r-mode)
:init
(require 'poly-R)
(require 'poly-markdown)
:config
(add-to-list 'auto-mode-alist '("\\.md$" . poly-markdown-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd$" . poly-markdown+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rcpp$" . poly-r+c++-mode))
(add-to-list 'auto-mode-alist '("\\.cppR$" . poly-c++r-mode))
)
这行得通。我按下M-n e,这会运行并生成一个 html 文档,最后程序会使用生成的 html 文件的内容打开 Firefox 浏览器。我想做的是只生成 html 文档但不打开浏览器。事实上,我通过 eww 在 emacs 中查看生成的 html 页面,并在每次 html 导出后按g 重新加载页面。
当我创建 Markdown 时,我将当前 Emacs 窗口拆分为三个缓冲区,如下所述:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Here is the buffer + +
+ in which I write + This eww buffer acts as +
+ my markdown file with + my web browser and +
+ my R programs. + shows the content of +
+++++++++++++++++++++++++++++ the generated HTML file +
+ Here is the buffer for + as if I was viewing it +
+ R to run the program + via Google Chrome, +
+ and generate the HTML + Firefox etc. +
+ file with all messages. + +
+ + Each time there is a new +
+ + version of the HTML +
+ + document I come back to +
+ + this buffer and after +
+ + pressing 'g' I reload +
+ + the page. +
+ + +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在 Emacs 中以这种方式工作对我来说似乎很方便。结果,没有理由在生成文件的每个新版本后打开 Firefox 窗口,这很烦人,每次我都必须手动关闭它。
所以我的问题是:是否有任何命令只运行程序并生成 HTML 文件而不用 Firefox 打开它?
【问题讨论】:
标签: r emacs r-markdown