Permalink
Browse files

Update to use flymake-easy

  • Loading branch information...
1 parent 31eec44 commit d79970fd6bebec05ebdb10d7371d0e9b14ec8b49 @purcell committed Nov 4, 2012
Showing with 18 additions and 33 deletions.
  1. +18 −33 flymake-jslint.el
View
51 flymake-jslint.el
@@ -1,20 +1,26 @@
-;;; flymake-jslint.el --- Flymake support for javascript using jslint
+;;; flymake-jslint.el --- A flymake handler for javascript using jslint
;;
;;; Author: Steve Purcell <steve@sanityinc.com>
;;; Homepage: https://github.com/purcell/flymake-jslint
;;; Version: DEV
+;;; Package-Requires: ((flymake-easy "0.1"))
;;
;;; Commentary:
;;
;; References:
;; http://www.emacswiki.org/cgi-bin/wiki/FlymakeJavaScript
;; http://d.hatena.ne.jp/kazu-yamamoto/mobile?date=20071029
;;
-;; Usage: (add-hook 'js-mode-hook 'flymake-jslint-load)
-(require 'flymake)
+;; Usage:
+;; (require 'flymake-jslint)
+;; (add-hook 'js-mode-hook 'flymake-jslint-load)
+;;
+;; Uses flymake-easy, from https://github.com/purcell/flymake-easy
;;; Code:
+(require 'flymake-easy)
+
(defgroup flymake-jslint nil
"Flymake checking of Javascript using jslint"
:group 'programming
@@ -37,42 +43,21 @@
(defvar flymake-jslint-trailing-comma-err-line-pattern
'("^\\(.+\\)\:\\([0-9]+\\)\: strict \\(warning: trailing comma.+\\)\:$" nil 2 nil 3))
-(defun flymake-jslint--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-jslint") nil ".js"))
-
-(defun flymake-jslint-init ()
+(defun flymake-jslint-command (filename)
"Construct a command that flymake can use to check javascript source."
- (list flymake-jslint-command (list "-process" (flymake-init-create-temp-buffer-copy
- 'flymake-jslint--create-temp-in-system-tempdir))))
+ (list flymake-jslint-command "-process" filename))
;;;###autoload
(defun flymake-jslint-load ()
- "Configure flymake mode to check the current buffer's javascript syntax.
-
-This function is designed to be called in `js-mode-hook' or
-equivalent; 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 javascript syntax."
(interactive)
- (set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-jslint-init)))
- (set (make-local-variable 'flymake-err-line-patterns) flymake-jslint-err-line-patterns)
- (when flymake-jslint-detect-trailing-comma
- (add-to-list 'flymake-err-line-patterns
- flymake-jslint-trailing-comma-err-line-pattern
- t))
- (if (executable-find flymake-jslint-command)
- (flymake-mode t)
- (message "Not enabling flymake: jsl 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-jslint-command
+ (append flymake-jslint-err-line-patterns
+ (when flymake-jslint-detect-trailing-comma
+ (list flymake-jslint-trailing-comma-err-line-pattern)))
+ 'tempdir
+ "js"))
(provide 'flymake-js)

0 comments on commit d79970f

Please sign in to comment.