Skip to content

Instantly share code, notes, and snippets.

@crowding
Created October 31, 2012 04:58
Show Gist options
  • Save crowding/3984881 to your computer and use it in GitHub Desktop.
Save crowding/3984881 to your computer and use it in GitHub Desktop.
Flymake support for R code
;; R flymake support (if Flymake is available) This will call a script
;; "rflymake" with the path given; make sure it is on emac's exec-path
;; or give a full path.
(when (require 'flymake nil)
(defun flymake-r-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "~/bin/rflymake" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks '("\\.[Rr]\\'" flymake-r-init))
(add-to-list 'flymake-err-line-patterns
'("parse(\"\\([^\"]*\\)\"): \\([0-9]+\\):\\([0-9]+\\): \\(.*\\)$"
1 2 3 4))
(add-hook 'r-mode-hook 'flymake-mode)
)
#!/usr/bin/env Rscript --no-init-file
#Parse a file and print the first error encountered.
args <- commandArgs(trailingOnly=TRUE)
filename = args[[1]]
tryCatch(invisible(do.call("parse", list(filename))), error=print)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment