Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Add flymake support for PHP.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Sep 6, 2014
1 parent 920dc89 commit c40df60
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions site-lisp/config/init-flymake.el
Expand Up @@ -148,6 +148,15 @@
(flymake-mode)
))

(add-hook 'php-mode-hook
(lambda ()
(require 'flymake)
(require 'flymake-extension)
(require 'flymake-php)
(flymake-mode)
(flymake-php-load)
))

(provide 'init-flymake)

;;; init-flymake.el ends here
39 changes: 39 additions & 0 deletions site-lisp/extensions/flymake/flymake-php.el
@@ -0,0 +1,39 @@
;;; 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
;;; Package-Requires: ((flymake-easy "0.1"))
;;;
;;; Commentary:
;; Usage:
;; (require 'flymake-php)
;; (add-hook 'php-mode-hook 'flymake-php-load)
;;
;; 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)))

(defvar flymake-php-executable "php"
"The php executable to use for syntax checking.")

(defun flymake-php-command (filename)
"Construct a command that flymake can use to check php source."
(list flymake-php-executable "-l" "-f" filename))

;;;###autoload
(defun flymake-php-load ()
"Configure flymake mode to check the current buffer's php syntax."
(interactive)
(flymake-easy-load 'flymake-php-command
flymake-php-err-line-patterns
'tempdir
"php"))


(provide 'flymake-php)
;;; flymake-php.el ends here

0 comments on commit c40df60

Please sign in to comment.