I'm trying to create a small interactive elisp function in order to quickly display a layout suitable for answering a Stackoverflow question about R. The idea is to open a temporary R file, and launch an R session associated to it in another frame.
So far I wrote this very simple thing :
(defun jb-so ()
"Start R for StackOverflow layout"
(interactive)
(find-file "/tmp/so.R")
(new-frame)
(R))
It's almost ok except for two details :
/tmp. Is there a way to accept it automatically ?*R* by default, but I'd like to give it a specific name, such as *RSo* in order to avoid conflicts with other running or future sessions. Is there a way to do it directly from the function ?Thanks in advance !
There are plenty of options that ess respects on startup. So emacs dynamic scope really helps here:
(defun jb-so ()
"Start R for StackOverflow layout"
(interactive)
(find-file "/tmp/so.R")
(let ((ess-ask-for-ess-directory nil)
(inferior-ess-same-window nil)
(ess-gen-proc-buffer-name-function (lambda (nm) "*RSO*")))
(R)
(pop-to-buffer "so.R")))
Note that this will work only in the recent versions of ESS that provide the facility to set custom names for process buffers (see ess-gen-proc-buffer-name-function). You can also rename inferior buffers with M-x rename-buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With