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"))
Thanks to:
- Airead (https://github.com/Airead) for testing.
- Fredrik Bergroth
- Yasuyuki Oka (https://github.com/yasuyk) for committing a patch.
- Fixed typo.
- Replaced incf and decf.
- Added check if
autopep8
executable is present.
- Added options to change
autopep8
’s behaviour.
- Renamed functions: This will break your code.
Copyright (c) 2013-2014, Friedrich Paetzke (paetzke@fastmail.fm). All rights reserved.