Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to disable the hook on a per buffer basis #21

Open
jerryasher opened this issue Sep 29, 2016 · 3 comments
Open

Would like to disable the hook on a per buffer basis #21

jerryasher opened this issue Sep 29, 2016 · 3 comments

Comments

@jerryasher
Copy link

When editing other people's code, I would like to disable the hook on a per buffer basis so I don't change their whitespace or other aspects of their code.

Are you open to a change like this in py-autopep8.el?

;;;###autoload
(defun py-autopep8-enable-on-save ()
  "Pre-save hook to be used before running autopep8."
  (interactive)
  (if current-prefix-arg
      (progn
        (remove-hook 'before-save-hook 'py-autopep8-buffer t)
        (message "py-autopep8-buffer removed"))
    (add-hook 'before-save-hook 'py-autopep8-buffer nil t)))

I can create a pull request if so, otherwise, I am open to your preferences...

Thanks

@chongchonghe
Copy link

I'm in great demand of this feature as well. I wish there is a way to disable py-autopep8 for the current buffer.

@jerryasher
Copy link
Author

Pull request #23 should address this.

@ideasman42
Copy link

Melpa now points to a fork of this package maintained here: https://github.com/ideasman42/emacs-py-autopep8

Formatting on save first calls py-autopep8-on-save-p which you can configure to a function (defaulting to 'always).
There is an included function 'py-autopep8-check-pyproject-exists-with-autopep8 that only auto-formats when you have autopep8 configured for the project. But if you want to check something else you can set this to your own function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants