- Flash Gordon
- May 8, 2006
-
Death To Ming
|
I'm using Spacemacs and despite it having an ess layer I'm having trouble getting it to play nicely with .Rnw files. There doesn't seem to be a easy command that will knit the file and create a pdf. I am trying to put something in my user config so that I can just type SPC-m-o-c and it will run the commands:
code:Rscript -e "library(knitr); knit('filename.Rnw')" && pdflatex filename.tex
but I can't seem to get it to work. Here is what I currently have, it gives me an error about 'wrong type argument: stringp, nil'.:
code: (add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(defun custom-knit ()
(let ((rnw-file))
(setq rnw-file (buffer-file-name))
(concat "Rscript -e \"library(knitr); knit('" rnw-file
"')\" && pdflatex " (file-name-base buffer-file-name) ".tex")
)
)
(spacemacs/set-leader-keys-for-major-mode
'Rnw-mode "moc" (shell-command (custom-knit)))
EDIT: Alright, got it working by adding the following two items to my .spacemacs:
code:;; in user-init()
(setq ess-swv-processor "knitr")
(setq ess-swv-pdflatex-commands (quote ("pdflatex" "texti2pdf" "make")))
;; in user-config()
(spacemacs/set-leader-keys "moc" '(lambda () (interactive)
(ess-swv-PDF "pdflatex")))
I still need to manually start an R instance when I open up a .Rnw file (and it doesn't seem to switch to the proper major mode automatically) but it's close!
Flash Gordon fucked around with this message at 02:25 on Mar 3, 2016
|
#
¿
Mar 3, 2016 02:07
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 13, 2024 03:45
|
|