py-autopep8.el icon indicating copy to clipboard operation
py-autopep8.el copied to clipboard

py-autopep8.el integrates autopep8 into Emacs.

  • py-autopep8.el

[[https://travis-ci.org/paetzke/py-autopep8.el][https://travis-ci.org/paetzke/py-autopep8.el.svg?branch=master]] [[http://melpa.org/#/py-autopep8][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=:

#+BEGIN_SRC bash $ pip install autopep8 $ wget https://raw.githubusercontent.com/paetzke/py-autopep8.el/master/py-autopep8.el
-O /your/path/py-autopep8.el #+END_SRC

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

#+BEGIN_SRC lisp (require 'py-autopep8) (add-hook 'python-mode-hook 'py-autopep8-enable-on-save) #+END_SRC

You can install =py-autopep8= also with [[https://github.com/milkypostman/melpa][MELPA]]:

#+BEGIN_SRC lisp M-x package-install RET py-autopep8 RET #+END_SRC

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.

#+BEGIN_SRC lisp (setq py-autopep8-options '("--max-line-length=100")) #+END_SRC

** 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 [[https://github.com/paetzke/py-autopep8.el/graphs/contributors][contributors]] have done so.