Yoichi's diary


2015-03-16

_ [python][emacs] flake8 with flymake

Qiita:Python の Lint (文法チェッカ) まとめ - flake8 + hacking を使う -によるとflake8使えということらしいので、

% pip3 install hacking
Downloading/unpacking hacking
...
Successfully installed hacking pep8 flake8 mccabe pbr
Cleaning up...

とインストールして、~/.emacs.d/init.el に

(defun flymake-python-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 "flake8" (list local-file))))
(when (load "flymake" t)
  (add-to-list 'flymake-allowed-file-name-masks
	       '("\\.py\\'" flymake-python-init)))
(add-hook 'python-mode-hook '(lambda () (flymake-mode)))

と書いてflymakeで使うようにしといた。