EMACS: Add flymake for PHP

This commit is contained in:
Tom Willemsen 2011-09-06 10:49:46 +02:00
parent 135bbeceaf
commit b90c7ddf68

View file

@ -158,6 +158,25 @@
(add-hook 'c-mode-common-hook 'oni/c-mode-common-hook) (add-hook 'c-mode-common-hook 'oni/c-mode-common-hook)
(add-hook 'c-mode-hook 'oni/c-mode-hook) (add-hook 'c-mode-hook 'oni/c-mode-hook)
;;; Flymake
(require 'flymake)
(defun flymake-php-init ()
"Use php to check the syntax of the current file."
(let* ((temp (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local (file-relative-name temp (file-name-directory
buffer-file-name))))
(list "php" (list "-f" local "-l"))))
(add-to-list
'flymake-err-line-patterns
'("\\(Parse\\|Fatal\\) error: +\\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)$"
3 4 nil 2))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.php$" flymake-php-init))
;;; PHP mode ;;; PHP mode
(defun oni/php-show-outline () (defun oni/php-show-outline ()
(interactive) (interactive)
@ -168,7 +187,10 @@
(c-set-offset 'arglist-close '0) (c-set-offset 'arglist-close '0)
(local-set-key [f6] 'comment-line) (local-set-key [f6] 'comment-line)
(local-set-key [f7] 'oni/php-show-outline) (local-set-key [f7] 'oni/php-show-outline)
(set-column-markers 76 81)) (local-set-key [M-S-up] 'flymake-goto-prev-error)
(local-set-key [M-S-down] 'flymake-goto-next-error)
(set-column-markers 76 81)
(flymake-mode 1))
(autoload 'php-mode "php-mode" "Major mode for PHP" t) (autoload 'php-mode "php-mode" "Major mode for PHP" t)
(setq-default php-mode-warn-if-mumamo-off nil) ; don't warn me about this (setq-default php-mode-warn-if-mumamo-off nil) ; don't warn me about this