Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0dedc96
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
;;; flymake-php.el --- A flymake handler for php-mode files | ||
;; | ||
;;; Author: Steve Purcell <steve@sanityinc.com> | ||
;;; URL: https://github.com/purcell/flymake-php | ||
;;; Version: DEV | ||
;;; | ||
;;; Commentary: | ||
;; Usage: | ||
;; (require 'flymake-php) | ||
;; (add-hook 'php-mode-hook 'flymake-php-load) | ||
(require 'flymake) | ||
|
||
(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") | ||
|
||
;; Invoke php with '-f' to get syntax checking | ||
(defun flymake-php-init () | ||
(list flymake-php-executable | ||
(list "-f" (flymake-init-create-temp-buffer-copy | ||
'flymake-create-temp-inplace) "-l"))) | ||
|
||
;;;###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 `flymake-mode' | ||
alone will not suffice." | ||
(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))) | ||
|
||
|
||
(provide 'flymake-php) | ||
;;; flymake-php.el ends here |