A nice emacs trick : using flymake-mode and this python code styles PEP8 checker script written by Johann C. Rocholl, we can have automatic real time checking for standard python coding style.
To make this work I copied the script (pep8.py) in my PATH, and then I added this block of code in my .emac file :
(when (load "flymake" t)
(defun flymake-pylint-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 "pep8.py" (list "--repeat" local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))
After this I can just enable flymake mode when I edit a python file, and every coding style error will be highlighted on the fly.
9 comments:
pep8.py not available.
Can you attach it to your post?
Dixon : you can find a copy of the script here.
Thank you very match!!
You made me happy!! :)
>coding style error will be highlighted on the fly
I made the same. I coding style error will be highlighted, but I don't see simple coding error (undefined variables, etc).
Do you see coding error?
Exactly, I use pyflakes in python mode:
(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)))
And pyflakes and pep8.py don't work together.
It could be possible to use pyflake and PEP8.py at the same time by concatenating the output from both programs. Too bad pyflake (or pylint) both don't allow to check the codding style.
I have solution!
http://stackoverflow.com/questions/1259873/how-can-i-use-emacs-flymake-mode-for-python-with-pyflakes-and-pylint-checking-cod
Wow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is great, let alone the content!
If some one wishes expert view about blogging and site-building then i suggest him/her to pay a visit this website, Keep up the pleasant work.
Post a Comment