Emacs ESS:R REPL 的管道输出到缓冲区
Emacs ESS: pipe output from R REPL into buffer
我希望能够在 R 的 REPL 上执行语句,并可以选择将其通过管道传输到缓冲区,以便我稍后可以快速参考它。
到 运行 一个 shell 命令并输出到 *shell command buffer*
我可以按照 this question 使用 M-!
。如果不求助于 write.csv()
,R 的 REPL 的等价物是什么?
您可以使用 ess-inf
中的 ess-command
将输出重定向到另一个缓冲区。示例如下所示,
(defun redirect-ess-output (command &optional buffer process)
(interactive (list (read-from-minibuffer "Command: ")))
(let ((buff (get-buffer-create (or buffer "*r-output*")))
;; 'ess-get-process' defaults to process local to current
;; buffer, so to call from anywhere default to "R"
(proc (ess-get-process (or process "R"))))
;; send a trailing newline to process
(unless (string-match-p "\n$" command)
(setq command (concat command "\n")))
(ess-command command buff 'sleep nil nil proc)
(with-current-buffer buff
;; process stuff
(pop-to-buffer buff))))
我希望能够在 R 的 REPL 上执行语句,并可以选择将其通过管道传输到缓冲区,以便我稍后可以快速参考它。
到 运行 一个 shell 命令并输出到 *shell command buffer*
我可以按照 this question 使用 M-!
。如果不求助于 write.csv()
,R 的 REPL 的等价物是什么?
您可以使用 ess-inf
中的 ess-command
将输出重定向到另一个缓冲区。示例如下所示,
(defun redirect-ess-output (command &optional buffer process)
(interactive (list (read-from-minibuffer "Command: ")))
(let ((buff (get-buffer-create (or buffer "*r-output*")))
;; 'ess-get-process' defaults to process local to current
;; buffer, so to call from anywhere default to "R"
(proc (ess-get-process (or process "R"))))
;; send a trailing newline to process
(unless (string-match-p "\n$" command)
(setq command (concat command "\n")))
(ess-command command buff 'sleep nil nil proc)
(with-current-buffer buff
;; process stuff
(pop-to-buffer buff))))