Guest User

Untitled

a guest
Sep 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. (use-package polymode
  2. :ensure t
  3. :config
  4. (use-package poly-R)
  5. (use-package poly-markdown)
  6. ;;; MARKDOWN
  7. (add-to-list 'auto-mode-alist '("\.md" . poly-markdown-mode))
  8. ;;; R modes
  9. (add-to-list 'auto-mode-alist '("\.Snw" . poly-noweb+r-mode))
  10. (add-to-list 'auto-mode-alist '("\.Rnw" . poly-noweb+r-mode))
  11. (add-to-list 'auto-mode-alist '("\.Rmd" . poly-markdown+r-mode))
  12. (markdown-toggle-math t)
  13. ;; from https://gist.github.com/benmarwick/ee0f400b14af87a57e4a
  14. ;; compile rmarkdown to HTML or PDF with M-n s
  15. ;; use YAML in Rmd doc to specify the usual options
  16. ;; which can be seen at http://rmarkdown.rstudio.com/
  17. ;; thanks http://roughtheory.com/posts/ess-rmarkdown.html
  18. (defun ess-rmarkdown ()
  19. "Compile R markdown (.Rmd). Should work for any output type."
  20. (interactive)
  21. ; Check if attached R-session
  22. (condition-case nil
  23. (ess-get-process)
  24. (error
  25. (ess-switch-process)))
  26. (let* ((rmd-buf (current-buffer)))
  27. (save-excursion
  28. (let* ((sprocess (ess-get-process ess-current-process-name))
  29. (sbuffer (process-buffer sprocess))
  30. (buf-coding (symbol-name buffer-file-coding-system))
  31. (R-cmd
  32. (format "library(rmarkdown); rmarkdown::render("%s")"
  33. buffer-file-name)))
  34. (message "Running rmarkdown on %s" buffer-file-name)
  35. (ess-execute R-cmd 'buffer nil nil)
  36. (switch-to-buffer rmd-buf)
  37. (ess-show-buffer (buffer-name sbuffer) nil)))))
  38. )
  39.  
  40. (with-eval-after-load 'polymode
  41. (define-key polymode-mode-map (kbd "<f5>") 'ess-rmarkdown))
  42.  
  43. Symbol's value as variable is void: polymode-mode-map
Add Comment
Please, Sign In to add comment