Created
October 28, 2012 03:14
-
-
Save uehaj/3967297 to your computer and use it in GitHub Desktop.
Flymake mode for groovy.
This file contains hidden or 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
| ;; flymake for groovy | |
| ;; setup: | |
| ;;(when (require 'flymake-groovy nil t) | |
| ;; (add-hook 'groovy-mode-hook | |
| ;; (lambda () (define-key groovy-mode-map "\C-ce" 'next-flymake-error)))) | |
| (require 'flymake) | |
| (defvar groovyc-command | |
| (expand-file-name (concat (getenv "GROOVY_HOME") "/bin/groovyc"))) | |
| ;; Invoke groovyc for compile with syntax checking | |
| (defun flymake-groovy-init () | |
| (let* ((temp-file (flymake-init-create-temp-buffer-copy | |
| 'flymake-create-temp-with-folder-structure)) | |
| (local-file (file-relative-name | |
| temp-file | |
| (file-name-directory buffer-file-name)))) | |
| (list groovyc-command (list "-d" "/tmp" local-file)) | |
| )) | |
| (push '(".+\\.groovy$" flymake-groovy-init) flymake-allowed-file-name-masks) | |
| (push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3) flymake-err-line-patterns) | |
| (add-hook | |
| 'groovy-mode-hook | |
| '(lambda () | |
| (if (not (null buffer-file-name)) (flymake-mode)))) | |
| (defun credmp/flymake-display-err-minibuf () | |
| "Displays the error/warning for the current line in the minibuffer" | |
| (interactive) | |
| (let* ((line-no (flymake-current-line-no)) | |
| (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no))) | |
| (count (length line-err-info-list)) | |
| ) | |
| (while (> count 0) | |
| (when line-err-info-list | |
| (let* ((file (flymake-ler-file (nth (1- count) line-err-info-list))) | |
| (full-file (flymake-ler-full-file (nth (1- count) line-err-info-list))) | |
| (text (flymake-ler-text (nth (1- count) line-err-info-list))) | |
| (line (flymake-ler-line (nth (1- count) line-err-info-list)))) | |
| (message "[%s] %s" line text) | |
| ) | |
| ) | |
| (setq count (1- count))))) | |
| (defun flymake-display-err-menu-for-current-line () | |
| "Displays the error/warning for the current line in popup(needs popup.el in auto-complete)" | |
| (interactive) | |
| (let* ((line-no (flymake-current-line-no)) | |
| (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))) | |
| (when line-err-info-list | |
| (let* ((count (length line-err-info-list)) | |
| (menu-item-text nil)) | |
| (while (> count 0) | |
| (setq menu-item-text (flymake-ler-text (nth (1- count) line-err-info-list))) | |
| (let* ((file (flymake-ler-file (nth (1- count) line-err-info-list))) | |
| (line (flymake-ler-line (nth (1- count) line-err-info-list)))) | |
| (if file | |
| (setq menu-item-text (concat menu-item-text " - " file "(" (format "%d" line) ")")))) | |
| (setq count (1- count)) | |
| (if (> count 0) (setq menu-item-text (concat menu-item-text "\n"))) | |
| ) | |
| (popup-tip menu-item-text))))) | |
| (defun next-flymake-error () | |
| "Displays the error/warning for the current line in the minibuffer" | |
| (interactive) | |
| (flymake-goto-next-error) | |
| (let ((err (get-char-property (point) 'help-echo))) | |
| (when err | |
| (message err)))) | |
| (provide 'flymake-groovy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment