Provides the py-autopep8
command, which uses the external autopep8
tool to tidy up the current buffer according to Python’s PEP8.
Install autopep8
and download py-autopep8.el
$ pip install autopep8
$ wget http://git.vanneva.com/py-autopep8.el.git/blob_plain/HEAD:/py-autopep8.el \
-O /your/path/py-autopep8.el
Add the before-save-hook to your ~/.emacs
(add-to-list 'load-path "/your/path/")
(require 'py-autopep8)
(add-hook 'before-save-hook 'py-autopep8-before-save)
You can also install py-autopep8 with MELPA:
M-x package-install RET
py-autopep8 RET
Now every time you save your Python file autopep8 will be executed on the current buffer.
To customize the behaviour of “autopep8” you can set the py-autopep8-options e.g.
(setq py-autopep8-options '("--max-line-length=100"))