Skip to content

Instantly share code, notes, and snippets.

@tototoshi
Created October 27, 2010 04:13
Show Gist options
  • Save tototoshi/648421 to your computer and use it in GitHub Desktop.
Save tototoshi/648421 to your computer and use it in GitHub Desktop.
my-flymake-config.el
;;;;;;;;;;;;;
;; flymake ;;
;;;;;;;;;;;;;
;; Flymake PHP Extension
(require 'flymake)
;; flymake
(when (require 'flymake nil t)
(global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line)
;; PHP
(when (not (fboundp 'flymake-php-init))
(defun flymake-php-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "php" (list "-f" local-file "-l"))))
(setq flymake-allowed-file-name-masks
(append
flymake-allowed-file-name-masks
'(("\(\.php[345]?|\.wui|\.view\|\.ediit|\.check|\.inc)$" flymake-php-init))))
(setq flymake-err-line-patterns
(cons
'("\(\(?:Parse error\|Fatal error\|Warning\): .*\) in \(.*\) on line \([0-9]+\)" 2 3 nil 1)
flymake-err-line-patterns)))
;; JavaScript
(when (not (fboundp 'flymake-javascript-init))
(defun flymake-javascript-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "/usr/local/bin/jsl" (list "-process" local-file))))
(setq flymake-allowed-file-name-masks
(append
flymake-allowed-file-name-masks
'(("\.json$" flymake-javascript-init)
("\.js$" flymake-javascript-init))))
(setq flymake-err-line-patterns
(cons
'("\(.+\)(\([0-9]+\)): \(?:lint \)?\(\(?:Warning\|SyntaxError\):.+\)" 1 2 nil 3)
flymake-err-line-patterns)))
;; Ruby
(when (not (fboundp 'flymake-ruby-init))
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
'("ruby" '("-c" local-file)))))
(add-hook 'php-mode-hook
'(lambda () (flymake-mode t)))
(add-hook 'js-mode-hook
(lambda () (flymake-mode t)))
(add-hook 'ruby-mode-hook
(lambda () (flymake-mode t))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment