Permalink
Browse files

Update to use flymake-easy

  • Loading branch information...
1 parent f3ce01e commit 41915adaaf3b8cd22fcb3cf9da5941a54c47335b @purcell committed Nov 4, 2012
Showing with 12 additions and 23 deletions.
  1. +12 −23 flymake-haml.el
View
@@ -1,33 +1,28 @@
-;;; flymake-haml.el --- Flymake handler for haml files
+;;; flymake-haml.el --- A flymake handler for haml files
;;
;;; Author: Steve Purcell <steve@sanityinc.com>
;;; URL: https://github.com/purcell/flymake-haml
;;; Version: DEV
+;;; Package-Requires: ((flymake-easy "0.1"))
;;
;;; Commentary:
;;
;; Usage:
;; (require 'flymake-haml)
;; (add-hook 'haml-mode-hook 'flymake-haml-load)
-(require 'flymake)
+;;
+;; Uses flymake-easy, from https://github.com/purcell/flymake-easy
;;; Code:
-(defvar flymake-haml-err-line-patterns '(("^Syntax error on line \\([0-9]+\\): \\(.*\\)$" nil 1 nil 2)))
-
-(defun flymake-haml--create-temp-in-system-tempdir (file-name prefix)
- "Return a temporary file name into which flymake can save buffer contents.
+(require 'flymake-easy)
-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-haml") nil ".haml"))
+(defconst flymake-haml-err-line-patterns '(("^Syntax error on line \\([0-9]+\\): \\(.*\\)$" nil 1 nil 2)))
;; Invoke utilities with '-c' to get syntax checking
-(defun flymake-haml-init ()
+(defun flymake-haml-command (filename)
"Construct a command that flymake can use to check haml source."
- (list "haml" (list "-c" (flymake-init-create-temp-buffer-copy
- 'flymake-haml--create-temp-in-system-tempdir))))
+ (list "haml" "-c" filename))
;;;###autoload
(defun flymake-haml-load ()
@@ -37,16 +32,10 @@ This function is designed to be called in `haml-mode-hook'; it
does not alter flymake's global configuration, so function
`flymake-mode' alone will not suffice."
(interactive)
- (set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-haml-init)))
- (set (make-local-variable 'flymake-err-line-patterns) flymake-haml-err-line-patterns)
- (if (executable-find "haml")
- (flymake-mode t)
- (message "Not enabling flymake: haml 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-haml-command
+ flymake-haml-err-line-patterns
+ 'tempdir
+ "haml"))
(provide 'flymake-haml)

0 comments on commit 41915ad

Please sign in to comment.