Last active
April 26, 2018 17:23
-
-
Save tmalsburg/773608cb9cca7f4121ef34c50372a0cd to your computer and use it in GitHub Desktop.
Elisp function for rendering RMarkdown files to PDF. Shows the output of the render process in a separate window.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun tmalsburg-rmarkdown-render () | |
"Compiles the current RMarkdown file to PDF and shows output of | |
the compiler process in a separate window." | |
(interactive) | |
(let* ((buf (get-buffer-create "*rmarkdown-render*")) | |
(temp-window (or (get-buffer-window buf) | |
(split-window-below -10))) | |
(command "Rscript -e 'library(rmarkdown); render(\"%s\", output_format=\"%s\")'") | |
(command (format command (buffer-file-name) "pdf_document"))) | |
(set-window-buffer temp-window buf) | |
(with-selected-window temp-window | |
(goto-char (point-max))) | |
(start-process-shell-command "rmarkdown-process" buf command))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment