とりあえず、 python とか難しいから、 flymake をフツーに入れてみる。
wget http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.4.0.tar.gz
tar xvzf pyflakes-0.4.0.tar.gz
cd pyflakes-0.4.0/
python setup.py install
で、 init.el は以下。よくわからないんだけど、 C とか Ruby とか一個一個書かなきゃ
いけないんだろうか。 javascript とかも難しそうだし・・・めんどくさい。
;; ------------------------------------------------------------------------
;; @ 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)
;; 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-display-err-menu-for-current-line)
;; c での設定
(defun flymake-cc-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 "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file))))
(push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks)
(add-hook 'c++-mode-hook
'(lambda ()
(flymake-mode t)))
;; 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]+\\): \\(.*\\)$" 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))))
[QED]
*********************************************************************************
0 件のコメント:
コメントを投稿