Permalink
Browse files

Update to use flymake-easy

  • Loading branch information...
purcell committed Nov 4, 2012
1 parent d623408 commit 329806582072afe4e9473c6e86dcdf4ae655b756
Showing with 17 additions and 37 deletions.
  1. +17 −37 flymake-coffee.el
View
@@ -1,61 +1,41 @@
-;;; flymake-coffee.el --- Flymake support for coffee script
+;;; flymake-coffee.el --- A flymake handler for coffee script
;;
;;; Author: Steve Purcell <steve@sanityinc.com>
;;; Homepage: https://github.com/purcell/flymake-coffee
;;; Version: DEV
+;;; Package-Requires: ((flymake-easy "0.1"))
;;
;;; Commentary:
;;
;; Based in part on http://d.hatena.ne.jp/antipop/20110508/1304838383
;;
-;; Usage: (add-hook 'coffee-mode-hook 'flymake-coffee-load)
-(require 'flymake)
+;; Usage:
+;; (require 'flymake-coffee)
+;; (add-hook 'coffee-mode-hook 'flymake-coffee-load)
+;;
+;; Uses flymake-easy, from https://github.com/purcell/flymake-easy
;;; Code:
+(require 'flymake-easy)
;; Doesn't strictly require coffee-mode, but will use 'coffee-command if set
(defconst flymake-coffee-err-line-patterns
- '(("\\(Error: In \\([^,]+\\), .+ on line \\([0-9]+\\).*\\)" 2 3 nil 1)))
-
-(defun flymake-coffee--create-temp-in-system-tempdir (file-name prefix)
- "Return a temporary file name into which flymake can save buffer contents.
-
-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-coffee") nil ".coffee"))
-
-(defun flymake-coffee-command ()
- "Return the location of the user's 'coffee' executable, using 'coffee-command if available."
- (if (boundp 'coffee-command)
- coffee-command
- "coffee"))
+ '(("^SyntaxError: In \\([^,]+\\), \\(.+\\) on line \\([0-9]+\\)" 1 3 nil 2)))
-(defun flymake-coffee-init ()
+(defun flymake-coffee-command (filename)
"Construct a command that flymake can use to check coffeescript source."
- (list (flymake-coffee-command)
- (list (flymake-init-create-temp-buffer-copy
- 'flymake-coffee--create-temp-in-system-tempdir))))
+ (list (if (boundp 'coffee-command) coffee-command "coffee")
+ filename))
;;;###autoload
(defun flymake-coffee-load ()
- "Configure flymake mode to check the current buffer's coffeescript syntax.
-
-This function is designed to be called in `coffee-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 coffeescript syntax."
(interactive)
- (set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-coffee-init)))
- (set (make-local-variable 'flymake-err-line-patterns) flymake-coffee-err-line-patterns)
- (if (executable-find (flymake-coffee-command))
- (flymake-mode t)
- (message "Not enabling flymake: coffee command not found")))
-
-
-(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-coffee-command
+ flymake-coffee-err-line-patterns
+ 'tempdir
+ "coffee"))
(provide 'flymake-coffee)

0 comments on commit 3298065

Please sign in to comment.