2011年6月1日

pyflakes のつづき・・・ [成功]

M-x shell だと pyflakes ができて、 M-x eshell だとできなかった。
cmd でもできないから、

Cygwin でインストールした pyflakes をコマンドプロンプトや flymake で動かしてみたり
http://stickydiary.blog88.fc2.com/blog-entry-105.html

を参考に、 pyflakes.bat を

@echo off
C:\gnupack_devel-6.02\app\cygwin\cygwin\bin /usr/bin/pyflakes %*

として、

C:\gnupack_devel-6.02\app\cygwin\cygwin\bin につくったら、うまく動いたけど、
C-cd のエラーがミニバッファに出ない。 Ruby とか C++ は出るのに。

ないよう分からずコピペしてるから、限界だろう。だれかやってくれないかなぁ。

init.el

;; ------------------------------------------------------------------------
;; @ 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))))

;; 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
 '("\\.py\\'" flymake-pyflakes-init)))

(add-hook 'find-file-hook 'flymake-find-file-hook)

0 件のコメント:

コメントを投稿