I want to be able to write R vignettes in org-mode. Crazy, perhaps, but it has become my default way to write everything, notes on current projects, even beamer slides and papers. Now I need to write a vignette for the coloc R package, and switching to Sweave reminds me what a pain that is. So I had a play with knitr before, and liked it, but again it means learning a new markup syntax.
I have found ox-ravel, which means I can now write .org files, and export part or all to Sweave, knitr, brew, etc. I cannot stress just how fantastic this is, in allowing me to write everything in one syntax!
But setting it up required updating org-mode, because it requires the new ox export engine found in org-8. In the process, I didn’t want to break org2blog which I use to write these blog posts. Knowing this could get complicated, I documented each step here.
I updated to org-8 using package.el in emacs.
M-x package-install RET org RET
(org-version) still said 7.8.11 though. To use the new org-8, I needed to add
~/.emacs before any org variables
Then I git cloned orgmode-accessories
git clone https://github.com/chasberry/orgmode-accessories.git
and followed the step by step instructions in
ox-ravel.org in the downloaded files, moving the resulting
ox-ravel.el file to somewhere in my load-path, and adding
I wrote a
vignette.org file which you can see at github and exporting it via
org-export-dispatch to any of the number of ravel-backends appears to work well. I can generate brew, markdown, Rnw files. You can see the .Rnw on github. I also added
vignettes/vignette.org to my
.Rbuildignore file so it wouldn’t confuse the R package builder.
Consulting https://github.com/ptrv/org2blog/tree/org-8-support, I did
git clone -b org-8-support https://github.com/ptrv/org2blog.git
to grab a branch of
org2blog that has been updated to work with org-8. I made sure the new org2blog, and not the old one, was in my emacs
load-path, and everything worked out of the box!