Last active
August 29, 2015 14:21
-
-
Save ChillarAnand/0e8c8351799cdd7254d7 to your computer and use it in GitHub Desktop.
autopep8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defcustom python-autopep8-path (executable-find "autopep8") | |
"autopep8 executable path." | |
:group 'python | |
:type 'string) | |
(defun python-autopep8 () | |
"Automatically formats Python code to conform to the PEP 8 style guide. | |
$ autopep8 --in-place --aggressive --aggressive <filename>" | |
(interactive) | |
(when (eq major-mode 'python-mode) | |
(shell-command | |
(format "%s --in-place --aggressive %s" python-autopep8-path | |
(shell-quote-argument (buffer-file-name)))) | |
(revert-buffer t t t))) | |
(bind-key "C-c C-a" 'python-auto-format) | |
(eval-after-load 'python | |
'(if python-autopep8-path | |
(add-hook 'before-save-hook 'python-autopep8))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment