Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to use flymake-easy

  • Loading branch information...
commit 91f867e209011af31a2ca2d8f6874b994403bcb2 1 parent 3bbe9cd
@purcell authored
Showing with 13 additions and 30 deletions.
  1. +13 −30 flymake-php.el
View
43 flymake-php.el
@@ -3,53 +3,36 @@
;;; Author: Steve Purcell <steve@sanityinc.com>
;;; URL: https://github.com/purcell/flymake-php
;;; Version: DEV
+;;; Package-Requires: ((flymake-easy "0.1"))
;;;
;;; Commentary:
;; Usage:
;; (require 'flymake-php)
;; (add-hook 'php-mode-hook 'flymake-php-load)
-(require 'flymake)
+;;
+;; Uses flymake-easy, from https://github.com/purcell/flymake-easy
;;; Code:
+(require 'flymake-easy)
-(defconst flymake-php-err-line-patterns '(("\\(?:Parse\\|Fatal\\|syntax\\) error[:,] \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1)))
+(defconst flymake-php-err-line-patterns
+ '(("\\(?:Parse\\|Fatal\\|syntax\\) error[:,] \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1)))
(defvar flymake-php-executable "php"
"The php executable to use for syntax checking.")
-(defun flymake-php--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-php") nil ".php"))
-
-;; Invoke php with '-f' to get syntax checking
-(defun flymake-php-init ()
+(defun flymake-php-command (filename)
"Construct a command that flymake can use to check php source."
- (list flymake-php-executable
- (list "-f" (flymake-init-create-temp-buffer-copy
- 'flymake-php--create-temp-in-system-tempdir) "-l")))
+ (list flymake-php-executable "-l" "-f" filename))
;;;###autoload
(defun flymake-php-load ()
- "Configure flymake mode to check the current buffer's php syntax.
-
-This function is designed to be called in `php-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 php syntax."
(interactive)
- (set (make-local-variable 'flymake-allowed-file-name-masks) '(("." flymake-php-init)))
- (set (make-local-variable 'flymake-err-line-patterns) flymake-php-err-line-patterns)
- (if (executable-find flymake-php-executable)
- (flymake-mode t)
- (message "Not enabling flymake: '%' command not found" flymake-php-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-php-command
+ flymake-php-err-line-patterns
+ 'tempdir
+ "php"))
(provide 'flymake-php)
Please sign in to comment.
Something went wrong with that request. Please try again.