Whenever I plot an R graphic in emacs ESS, it opens a new window. Is there a command to close it directly from emacs?
I was trying to create a keybind in my init.el file using something like
(setq ess-dev-off ‘(“dev.off()\n”)))
(eval-after-load “ess-mode”
‘(progn
(define-key dev-off “\C-cp” ‘ess-dev-off))
But of course is not working. Some advice on how to define my own keybind for that?
You can send R code to the inferior process using ess-send-string
,
(defun my-dev-off ()
(interactive)
(let ((proc (ess-get-process)))
(ess-send-string proc "dev.off()")))
(with-eval-after-load 'ess-r-mode
(define-key ess-r-mode-map (kbd "C-c p") #'my-dev-off))
If you want to bind a function to a keybinding, the function needs to an interactive function, ie. one that is defined with (interactive)
as the first form in its body.