Skip to content

paetzke/py-autopep8.el

Repository files navigation

py-autopep8.el

https://travis-ci.org/paetzke/py-autopep8.el.svg?branch=master http://melpa.org/packages/py-autopep8-badge.svg

Provides commands, which use the external autopep8 tool to tidy up the current buffer according to Python’s PEP8.

To install autopep8 and py-autopep8:

$ pip install autopep8
$ wget https://raw.githubusercontent.com/paetzke/py-autopep8.el/master/py-autopep8.el \
        -O /your/path/py-autopep8.el

Add the before-save-hook to your ~/.emacs:

(require 'py-autopep8)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)

You can install py-autopep8 also 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"))

Functions

M-x py-autopep8-buffer: Uses the autopep8 tool to reformat the current buffer.

Bugs and improvements

Feel free to open tickets or send pull requests with improvements. These contributors have done so.