牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

Emacs で Python の動的エラーチェックする『py26-pyflakes』 をMacPorts でインスコした時の設定

なんか動かないなーと少々悩んだのでメモ。

sudo port install py26-pyflakes

「Using flymake with pyflakes」の詳細はここ

上記リンクの設定だと動かないので
「pyflakes」を「/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/pyflakes」に書き換える

エラー出たりするので回避策

追加修正
ファイルによってエラー出ててしまう

Configuration error has occurred while running (/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/pyflakes hoge.py). Flymake will be switched OFF

なので下記リンクの回避策をとる

設定

(when (load "flymake" t)
  (defun flymake-pyflakes-init ()
     ; Make sure it's not a remote buffer or flymake would not work
    (when (not (subsetp (list (current-buffer)) (tramp-list-remote-buffers)))
      (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 "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/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)
;; error avoidance
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted)
  (setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)