Skip to content
Browse files

Update to use flymake-easy

  • Loading branch information...
1 parent 307a54f commit e14e8e2abda223bd3920dbad0eefd5af5973ae6d @purcell committed Nov 4, 2012
Showing with 14 additions and 30 deletions.
  1. +14 −30 flymake-ruby.el
View
44 flymake-ruby.el
@@ -3,54 +3,38 @@
;;; Author: Steve Purcell <steve@sanityinc.com>
;;; URL: https://github.com/purcell/flymake-ruby
;;; Version: DEV
+;;; Package-Requires: ((flymake-easy "0.1"))
;;;
;;; Commentary:
;; Usage:
;; (require 'flymake-ruby)
;; (add-hook 'ruby-mode-hook 'flymake-ruby-load)
-(require 'flymake)
+;;
+;; Uses flymake-easy, from https://github.com/purcell/flymake-easy
;;; Code:
-(defconst flymake-ruby-err-line-patterns '(("^\\(.*\.rb\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)))
+(require 'flymake-easy)
+
+(defconst flymake-ruby-err-line-patterns
+ '(("^\\(.*\.rb\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)))
(defvar flymake-ruby-executable "ruby"
"The ruby executable to use for syntax checking.")
-(defun flymake-ruby--create-temp-in-system-tempdir (file-name prefix)
- "Return a temporary file name into which flymake can save.
-
-This is tidier than `flymake-create-temp-inplace', and therefore
-preferable when the checking doesn't depend on the file's exact
-location."
- (make-temp-file (or prefix "flymake-ruby") nil ".rb"))
-
;; Invoke ruby with '-c' to get syntax checking
-(defun flymake-ruby-init ()
+(defun flymake-ruby-command (filename)
"Construct a command that flymake can use to check ruby source."
- (list flymake-ruby-executable
- (list "-w" "-c" (flymake-init-create-temp-buffer-copy
- 'flymake-ruby--create-temp-in-system-tempdir))))
+ (list flymake-ruby-executable "-w" "-c" filename))
;;;###autoload
(defun flymake-ruby-load ()
- "Configure flymake mode to check the current buffer's ruby syntax.
-
-This function is designed to be called in `ruby-mode-hook'; it
-does not alter flymake's global configuration, so function
-`flymake-mode' alone will not suffice."
+ "Configure flymake mode to check the current buffer's ruby syntax."
(interactive)
- (set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-ruby-init)))
- (set (make-local-variable 'flymake-err-line-patterns) flymake-ruby-err-line-patterns)
- (if (executable-find flymake-ruby-executable)
- (flymake-mode t)
- (message "Not enabling flymake: '%s' command not found" flymake-ruby-executable)))
-
-
-(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
- (setq flymake-check-was-interrupted t))
-(ad-activate 'flymake-post-syntax-check)
-
+ (flymake-easy-load 'flymake-ruby-command
+ flymake-ruby-err-line-patterns
+ 'tempdir
+ "rb"))
(provide 'flymake-ruby)
;;; flymake-ruby.el ends here

0 comments on commit e14e8e2

Please sign in to comment.
Something went wrong with that request. Please try again.