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

What is the best way to disable prelude-python-mode-set-encoding? #1292

Closed
ryukinix opened this issue Oct 5, 2020 · 8 comments · Fixed by #1293
Closed

What is the best way to disable prelude-python-mode-set-encoding? #1292

ryukinix opened this issue Oct 5, 2020 · 8 comments · Fixed by #1293

Comments

@ryukinix
Copy link
Contributor

ryukinix commented Oct 5, 2020

That feature it's annoying to be used on python3 because it's no longer necessary. On the current year, 2020, python2 is officially deprecated. I know that adding this prevents people using python2 having problem, but is not my case. I'm having problem to get my work accepted sometimes because I have that auto inserted line:

# coding: utf-8

In general is unrelated to the patch I sent and frequently on code review is requested to delete this. (unnecessary headaches)

So I'm asking how I can disable that auto-insertion using prelude-python module properly without the need to hack my own prelude version and giving me problems to update later. Currently, I just deleted that line:

(add-hook 'after-save-hook 'prelude-python-mode-set-encoding nil 'local))

But is not optimal. It would better if it have a variable to turn it off.

@bbatsov
Copy link
Owner

bbatsov commented Oct 6, 2020

Probably we should add a defcustom for this and disable it by default.

In the mean time you can just use remove-hook in your personal config.

@ryukinix
Copy link
Contributor Author

ryukinix commented Oct 6, 2020

In the mean time you can just use remove-hook in your personal config.

I tried that but didn't worked as expected, because that hook is inserted by another python hook here everytime that a buffer open:

(add-hook 'python-mode-hook (lambda ()
(run-hooks 'prelude-python-mode-hook)))

So I would need to remove the entire prelude-python-mode-hook to get a effective change.

Probably we should add a defcustom for this and disable it by default.

I agreed. If I made a PR, do you will accept it?

@bbatsov
Copy link
Owner

bbatsov commented Oct 6, 2020

Sure.

@ryukinix
Copy link
Contributor Author

ryukinix commented Oct 6, 2020

Ok, I'll fix it.

@ryukinix
Copy link
Contributor Author

ryukinix commented Oct 6, 2020

One doubt @bbatsov to make our code review easier later.

Probably we should add a defcustom for this and disable it by default.

  1. You mean something like prelude-python-mode-set-encoding-toggle and be nil as default, right? That way the default behavior will not insert # coding: utf-8 anymore.

  2. You mean prelude-python-mode-set-encoding-disable and be nil as default?

Can you confirm to me what option do you prefer?

@bbatsov
Copy link
Owner

bbatsov commented Oct 6, 2020

I meant 1)

I'd name the defcustom prelude-python-mode-set-encoding-automatically.

@ryukinix
Copy link
Contributor Author

ryukinix commented Oct 6, 2020

Thanks for answer it! Good name.

@ryukinix
Copy link
Contributor Author

ryukinix commented Oct 6, 2020

PR submitted, @bbatsov. Review it when you can.

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

Successfully merging a pull request may close this issue.

2 participants