Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set up flymake for ruby files.

  • Loading branch information...
commit eb4d3d5c1119c4358072a39ef88a8ffff9ba1eb7 1 parent 04b321f
@technomancy authored
Showing with 31 additions and 1 deletion.
  1. +31 −1 starter-kit-ruby.el
View
32 starter-kit-ruby.el
@@ -50,9 +50,39 @@ exec-to-string command, but it works and seems fast"
(add-hook 'ruby-mode-hook 'coding-hook)
+;;; Flymake
+
+(eval-after-load 'ruby-mode
+ '(progn
+ (require 'flymake)
+
+ ;; Invoke ruby with '-c' to get syntax checking
+ (defun flymake-ruby-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 "ruby" (list "-c" local-file))))
+
+ (push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
+ (push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
+
+ (push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
+ flymake-err-line-patterns)
+
+ (add-hook 'ruby-mode-hook
+ (lambda ()
+ (when (and buffer-file-name
+ (file-writable-p
+ (file-name-directory buffer-file-name))
+ (file-writable-p buffer-file-name))
+ (local-set-key (kbd "C-c d")
+ 'flymake-display-err-menu-for-current-line)
+ (flymake-mode t))))))
+
;; TODO: set up ri
;; TODO: electric
-;; TODO: flymake
(provide 'starter-kit-ruby)
;; starter-kit-ruby.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.