(defun ess-graphics-off () "Close all graphics devices." (interactive)
  (ess-eval-linewise "graphics.off()"))


(defun ess-load-and-maximize ()
  "Return from edit buffer to *R* session, uploading changes." (interactive)
  (ess-load-file buffer-file-name)(switch-to-buffer "*R*")
  (delete-other-windows))


(defun Rd-compile-html () "Compile Rd file to HTML." (interactive)
  (save-buffer)(compile (concat "R CMD Rdconv -t html -o "
    (file-name-sans-extension (buffer-name)) ".html " (buffer-name))))


(defun Rd-compile-latex () "Compile Rd file to LaTeX." (interactive)
  (save-buffer)(compile (concat "R CMD Rdconv -t latex -o "
    (file-name-sans-extension (buffer-name)) ".tex " (buffer-name))))


(defun Rd-link () "Insert \\code{\\link{}}." (interactive)
  (insert "\\code{\\link{}}")(search-backward "}}"))


(defun Rd-view-html ()
  "View HTML file with same prefix as current Rd file." (interactive)
  (browse-url (concat (file-name-sans-extension (buffer-file-name)) ".html")))
