This article will describe using py-yapf package which provides running yapf command. The yapf command is code formatter for python.
Table of Contents
1 Install py-yapf package
Install py-yapf package with M-x package-list-packages.
py-yapf 0.2 available Use yapf to beautify a Python buffer
2 Install yapf
Install yapf 0.2.7 with pip.
$ sudo pip install yapf==0.2.7
3 ${HOME}/.emacs
Add py-yapf-enable-on-save to python-mode-hook.
(add-hook 'python-mode-hook 'py-yapf-enable-on-save)
4 Execution result
There is no space between definitions of function before saving.
There are spaces between definitions of function after saving.