I am trying to run a command from Emacs using ESS, to send code to the R buffer (though I have stumbled onto this problem in python as well).
I can't figure out though how to use:
(ess-send-string PROCESS STRING)
I do not understand how I can, while calling this function from the script buffer, send a string to the associated *R* buffer.
I have tried using comint
and process-send-string
, but I guess I do not understand how to send a process. A buffer name did not do it, what will?
Example:
(defun create-rtags ()
(interactive)
(ess-send-string PROCESS "rtags(ofile=paste0(getwd(), \"TAGS\"))")
You can use get-process
to have the right process or ess-get-process
if you use the latest of ESS version on github.
(ess-send-string (get-process "R") "a <- 1:10;a")
Result in
[1] 1 2 3 4 5 6 7 8 9 10
So for your function, something like this should work
(defun create-rtags ()
(interactive)
(ess-send-string (get-process "R") "rtags(ofile = file.path(getwd(), \"TAGS\"))"))