Created
October 25, 2011 16:33
-
-
Save guehara/1313365 to your computer and use it in GitHub Desktop.
flymake for objc-mode
This file contains 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 | |
(require 'flymake) | |
(set-face-attribute 'flymake-errline nil | |
:background "slateblue4" | |
:foreground "aliceblue" | |
:weight 'normal) | |
(set-face-attribute 'flymake-warnline nil | |
:background "yellow" | |
:foreground "black" | |
:weight 'normal) | |
(defun flymake-display-err-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-minibuffer-safe () | |
(ignore-errors flymake-display-err-minibuffer)) | |
;; エラーが起きた時にflymakeを止める | |
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted) | |
(setq flymake-check-was-interrupted t)) | |
(ad-activate 'flymake-post-syntax-check) | |
(setq flymake-err-line-patterns | |
(cons | |
'("\\(.+\\):\\([0-9]+\\):\\([0-9]+\\): \\(.+\\)" 1 2 3 4) | |
flymake-err-line-patterns)) | |
; Makefile検索 | |
(defun search-makefile () | |
(if (file-exists-p "Makefile") | |
t | |
(cd "../") | |
(search-makefile))) | |
; Makefileが無いと固まるので対策 | |
(defun flymake-objc-init () | |
(if (search-makefile) | |
(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 "make" (list "-s" (format "-C%s" default-directory) | |
(format "CHK_SOURCES=%s" temp-file) "SYNTAX_CHECK_MODE=1" "check-syntax"))))) | |
(add-hook 'objc-mode-hook | |
(lambda () | |
(push '("\\.m$" flymake-objc-init) flymake-allowed-file-name-masks) | |
(push '("\\.h$" flymake-objc-init) flymake-allowed-file-name-masks) | |
(define-key objc-mode-map "\C-cd" 'flymake-display-err-minibuffer) | |
(push '("\\(.+\\):\\([0-9]+\\):\\([0-9]+\\): \\(.+\\)" 1 2 3 4) flymake-err-line-patterns) | |
(flymake-mode t) | |
)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment