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

[Feature Request] More friendly auto-correct features #21

Open
jimeh opened this issue Jan 31, 2016 · 3 comments
Open

[Feature Request] More friendly auto-correct features #21

jimeh opened this issue Jan 31, 2016 · 3 comments

Comments

@jimeh
Copy link

jimeh commented Jan 31, 2016

Update: I've achieved the goal of this feature request with a custom package called rubocopfmt. I will leave this issue open for others to see until @bbatsov feels it's appropriate to close it.


So due my lack of elisp skills, I have a badly hacked together set of tweaks to rubocop-mode that nearly makes the auto-correct stuff work the way I want: siren-rubocop.el

I'd love for something like these features to be available in rubocop-mode itself. The key features I'm after are:

  • Ability to automatically run auto-correct against current file on save, and have the local buffer update/revert instantly while retaining undo history.
  • Ability to trigger auto-correct for current file without the compile buffer opening. The compile buffer is annoying when auto-correcting on save, or if you manually want to quickly just auto-correct stuff and don't care for rubocop's output.
  • A way to turn auto-correct on save on/off. Maybe even with a minor-mode so it can easily be toggled on the fly rather than via a customizable variable.

As for my own hack, the only thing that's not working correctly is the instant revert/update when you run auto-correct. As far as I can figure I'm guessing compilation-start is async so the revert-buffer call fires after emacs has saved the file, but before rubocop has auto-corrected it.

@bbatsov
Copy link
Collaborator

bbatsov commented Jan 20, 2017

All of those things are trivial to implement, if only I had any free time these days... :-)

@yxhuvud
Copy link

yxhuvud commented May 21, 2018

Perhaps also an even more cautious auto-correct would be possible where only changes that involve lines that are changed in git would be auto-corrected. But perhaps that should be a suggestion for upstream rubocop instead, first.

@jimeh
Copy link
Author

jimeh commented May 21, 2018

My hacked together solution from two years ago when I opened this issue has now evolved into a fully fledged package called rubocopfmt: https://github.com/jimeh/rubocopfmt.el

@yxhuvud While it's not as intelligent as only correcting lines which are modified in git, rubocopfmt does disable a few cops which causes confusion and annoyance in the context of a text editor with potentially work-in-progress code whenever you save.

@bbatsov I'd appreciate your thoughts on rubocopfmt. Specifically if you're cool with it being it's own package, or if you'd prefer it being merged into your rubocop package. Also as of 5 minutes ago I am considering renaming the project to rubocop-on-save so it's more in-line with what the package actually does now.

Edit: Nevermind on the name change, probably best to leave it as the fmt part is a nod to gofmt. Also I already have a PR against MELPA open to add the package :P

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