;; ------------------------------------------------------------------------
;; @ flymake で間違っているところをハイライトし、エラーとかをミニバッファへ
;; http://shnya.jp/blog/?category_name=emacs
;; http://d.hatena.ne.jp/khiker/20070630/emacs_ruby_flymake
;; http://d.hatena.ne.jp/khiker/20070720/emacs_flymake
;; http://d.hatena.ne.jp/nyaasan/20071216/p1
(require 'flymake)
;; flymakeの色を変更
;; (set-face-background 'flymake-errline "red4")
;; (set-face-background 'flymake-warnline "dark slate blue")
;; ruby での設定
(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))))
(list "ruby" (list "-c" local-file))))
(push '(".+\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): file://(.*//)$" 1 2 nil 3)
flymake-err-line-patterns)
(add-hook
'ruby-mode-hook
'(lambda ()
;; Don't want flymake mode for ruby regions in rhtml files
(if (not (null buffer-file-name)) (flymake-mode))))
;; python での設定
;;===== PyFlakes
;; code checking via pyflakes+flymake
(when (load "flymake" t)
(defun flymake-pyflakes-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 "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("file://.py//'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
;; miniBuffer にエラーを出力
(defun flymake-show-and-sit ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(progn
(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)))))
(sit-for 60.0))
;; キー割り当て
(global-set-key "\M-gn" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-next-error)
(when (equal line (line-number-at-pos))
(next-error)))))
(global-set-key "\M-gp" '(lambda ()
(interactive)
(let (line (line-number-at-pos))
(flymake-goto-prev-error)
(when (equal line (line-number-at-pos))
(previous-error)))))
(global-set-key "\C-cd" 'flymake-show-and-sit)
0 件のコメント:
コメントを投稿