py-autopep8.el
py-autopep8.el copied to clipboard
Is this repository still active ?
Hi,
So first of all, thanks for this useful package. I forked this repo and started making some changes. Namely I refactored so that it is a minor-mode than can be enabled/disabled on a per-buffer basis. I'd like to know if you think I should drop the PR here or if I should push my own package to MELPA ? But there does not seem to have many activity around here...
Cheers
@wizmer This repo looks thoroughly unmaintained to me. I would welcome your fork.
@wizmer Do you have any interest in maintaining a fork? Or help me do it (I have no experience with melpa packaging)? I would love to have minor-mode in. I'm also looking to extend this to work with pyenv-mode
.
Hi,
So apparently one day I wrote that https://github.com/wizmer/py-autopep8.el/tree/minor-mode
I don't remember if it works, maybe that could be the starting point for your py-env
extension. I can maintain the fork or help you do it. It would be good if we can get back the ownership on Melpa, I'll have a look one of these day but not now as I am already pretty busy.
I used to run this code:
pip3 install autopep8
(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-autopep8)
(eval-after-load 'python
'(if python-autopep8-path
(add-hook 'before-save-hook 'python-autopep8)))
Found and modified from this link
But now my doom.el handles formatting for me.
@tavurth How do I use this with DOOM emacs ? the "original" instructions from this repo i.e.
(require 'py-autopep8)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
are not working for me.
I can not even manually call M-x py-autopep8-buffer
- it does not even appear when I type M-x
Hi @mandarvaze!
Please make sure the following two lines in your doom init.el
are uncommented:
(format +onsave) ; automated prettiness
...
python
Then when you save a python file, check your Messages (C-x B *Messages*
) buffer for errors, as I remember there where two applications I had to install to get it autoformatting, one was black
(pip install black
) and the other I've forgotten.
If you're having trouble, the doom emacs guys are very helpful and can probably help better than I.
@tavurth Thanks for the suggestion to check *Messages*
buffer
I keep seeing Error: (error "You need the \"black\" command. You may be able to install it via \"pip install black\".")
in the *Messages*
buffer.
I already have (format +onsave)
and python
enabled in init.el
I'm also using lsp
- I think the above is coming from lsp
(But I could be wrong)
I've already posted on doom-emacs discord server. Waiting for response.
@mandarvaze Yep, that I mentioned in my post, did you try installing black
already?
@tavurth I had black
which I removed cause I wanted to use autopep8
formatter instead of black
Anyway, Henrik (DOOM emacs creator) suggested how to get it working using set-formatter
command - which now works for me.
Edit:
If anyone comes looking, see this on how to use autopep8 with Doom emacs
I'm not using this package (i.e. py-autopep8.el) anymore with Doom. Just autopep8
directly (With Doom emacs)
Recently I've updated this package with fixes/improvements. Since it seems the original author is not active anymore, I'll check if Melpa could point to my repository instead.
Note that I tried mailing "Friedrich Paetzke" using the fastmail.fm
email from git, but it bounced.
Melpa now points to a fork of this package maintained here: https://github.com/ideasman42/emacs-py-autopep8