Skip to content

Instantly share code, notes, and snippets.

@ArneBab
Forked from st63jun/flymake-java.el
Created February 1, 2016 09:15
Show Gist options
  • Save ArneBab/dde7a2f7b1a081ecb30c to your computer and use it in GitHub Desktop.
Save ArneBab/dde7a2f7b1a081ecb30c to your computer and use it in GitHub Desktop.
Fix flymake+ant problem
;; 素のFlymakeでAntを使うとエラー吐くので,いくつか関数を書き換える必要があるっぽい.
(require 'flymake)
(setq flymake-allowed-file-name-masks
'(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
("\\.xml\\'" flymake-xml-init)
("\\.html?\\'" flymake-xml-init)
("\\.cs\\'" flymake-simple-make-init)
("\\.p[ml]\\'" flymake-perl-init)
("\\.php[345]?\\'" flymake-php-init)
("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
;;("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
("\\.java\\'" flymake-simple-ant-java-init flymake-master-cleanup) ; use ant instead of make
("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
("\\.tex\\'" flymake-simple-tex-init)
("\\.idl\\'" flymake-simple-make-init)
))
;; fix build.xml pathname error
(defun flymake-get-ant-cmdline (source base-dir)
(list "ant"
(list "-buildfile"
(concat base-dir "build.xml")
(concat "-DCHK_SOURCES=" source)
"check-syntax")))
;; fix base-dir pathname error
(defun flymake-init-find-buildfile-dir (source-file-name buildfile-name)
"Find buildfile, store its dir in buffer data and return its dir, if found."
(let* ((buildfile-dir
(flymake-find-buildfile buildfile-name
(file-name-directory source-file-name))))
(if buildfile-dir
(setq flymake-base-dir (expand-file-name buildfile-dir))
(flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
(flymake-report-fatal-status
"NOMK" (format "No buildfile (%s) found for %s"
buildfile-name source-file-name)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment