emacs-oob-reboot icon indicating copy to clipboard operation
emacs-oob-reboot copied to clipboard

Handle whitespace cleanup more intelligently

Open rski opened this issue 7 years ago • 19 comments

Cleaning up all the trailing whitespace in a buffer might not be a good default, mostly because of the reason pointed out in https://github.com/lewang/ws-butler:

Then I got a job working on a code base where no one else trimmed spaces, so my commits became super noisy.

Maybe ws-butler mode could be installed and enabled instead of a delete-trailing-whitespace hook?

rski avatar May 06 '17 06:05 rski

Is ws-butler-mode in ELPA?

A default using packages from MELPA probably won't get accepted.

josteink avatar May 06 '17 06:05 josteink

Unfortunately not. Still, I'd prefer no cleanup rather than really intrusive cleanup as most people working on whitespace codebases would. eg Eclipse tends to leave a lot of whitespace around so collaboration with Eclipse users would be a pain.

rski avatar May 06 '17 06:05 rski

The easiest way to get people to clean up their extra whitespace is enabling show-trailing-whitespace from both prog-mode-hook and text-mode-hook. The only downside of that is that it makes redisplay a bit slower.

wasamasa avatar May 06 '17 07:05 wasamasa

I think show-trailing-whitespace is a dubious default for much the same reason that trimming all trailing whitespace upon saving is a bad idea: As soon as you work on a version-controlled file where someone else has committed trailing whitespace, these supposedly helpful settings just generate unwanted noise.

ws-trim and ws-butler are the two libraries I know of which deal with the problem properly, and I think ws-trim might be a little too aggressive to use by default. I don't think either of them are in GNU ELPA in any case.

phil-s avatar May 06 '17 09:05 phil-s

@phil-s On the other hand, it would promote good practices in that team. It's also pretty straightforward to disable.

With that being said, I don't recall any editor/IDE that I've used showing trailing whitespaces and/or blank lines by default.

angrybacon avatar May 06 '17 10:05 angrybacon

@phil-s Disagree. Deleting trailing whitespace is better for use with git (and in general, IMO) and some other editors by default clean this up.

ssunday avatar May 07 '17 17:05 ssunday

@ssunday can't agree with you more.... languages like python even gets faulty with unwanted whitespaces. Even elisp with whitespaces gives you a warning with Flycheck. Definitely need this.

justinjk007 avatar May 07 '17 22:05 justinjk007

I would consider showing whitespaces. Deleting is way to intrusive (and opinionated) in my opinion, same thing for newline at the end of files.

angrybacon avatar May 07 '17 23:05 angrybacon

I used to have the setting to auto-delete whitespace on my Emacs, until I started having to deal with conflicts on almost all merges on a really whitespace-dirty (python) codebase. Definitely not a good standard.

edcrypt avatar May 12 '17 14:05 edcrypt

A default causing merge conflicts in a popular language is not good. We should definitely avoid that.

josteink avatar May 12 '17 16:05 josteink

I never thought about Refactoring dirty code-base actually that's my in-experience. But I will definitely have it on when I am starting something new.

justinjk007 avatar May 13 '17 15:05 justinjk007

Emacs shouldn't be annoying to new users or create extra work for them by default, so cleaning up whitespace shouldn't be enabled by default. Highlighting trailing whitespace would be okay, but maybe still not a good idea.

What would definitely be a good idea would be to mention these modes (the best one, whichever it may be) in a short-and-sweet "recommended addons" list that's linked on the startup screen.

alphapapa avatar May 13 '17 18:05 alphapapa

If we are adding Flycheck then trailing whitespace will be automatically highlighted as a warning.

justinjk007 avatar May 13 '17 19:05 justinjk007

If we are adding Flycheck then trailing whitespace will be automatically highlighted as a warning.

In which flycheck modes? I've never noticed that.

alphapapa avatar May 13 '17 19:05 alphapapa

In Python and elisp. But I could check for other modes too.

justinjk007 avatar May 13 '17 19:05 justinjk007

Emacs shouldn't be annoying to new users or create extra work for them by default, so cleaning up whitespace shouldn't be enabled by default. Highlighting trailing whitespace would be okay, but maybe still not a good idea.

Totally agreed.

If we are adding Flycheck then trailing whitespace will be automatically highlighted as a warning.

Let's not assume flycheck gets added right yet. For now it's a MELPA package, and those are a no go.

In which flycheck modes? I've never noticed that.

Indeed. This is mode-specific behaviour, so it doesn't really solve any whitespace-problem specifically, only incidentally at best. With a MELPA-package we can't use.

I guess now that this has shown to be such a contentious issue, maybe we should just revert auto-cleanup of whitespace. Anyone strongly against such a decision?

josteink avatar May 13 '17 19:05 josteink

I agree, for the revert

On Sat, May 13, 2017, 3:15 PM Jostein Kjønigsen [email protected] wrote:

Emacs shouldn't be annoying to new users or create extra work for them by default, so cleaning up whitespace shouldn't be enabled by default. Highlighting trailing whitespace would be okay, but maybe still not a good idea.

Totally agreed.

If we are adding Flycheck then trailing whitespace will be automatically highlighted as a warning.

Let's not assume flycheck gets added right yet. For now it's a MELPA package, and those are a no go.

In which flycheck modes? I've never noticed that.

Indeed. This is mode-specific behaviour, so it doesn't really solve any whitespace-problem specifically, only incidentally at best. With a MELPA-package we can't use.

I guess now that this has shown to be such a contentious issue, maybe we should just revert auto-cleanup of whitespace. Anyone strongly against such a decision?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/josteink/emacs-oob-reboot/issues/19#issuecomment-301268891, or mute the thread https://github.com/notifications/unsubscribe-auth/AMUYO2ihEDbzGJDrDtE3GmtHZ39Gl8Azks5r5gE-gaJpZM4NSpLh .

justinjk007 avatar May 13 '17 19:05 justinjk007

I also agree with removing this. Although I use it myself, there are corner cases where whitespace is significant, and it would be puzzling and frustrating if emacs is silently deleting it.

I would support showing whitespace by default. Whitespace is significant in many languages, and being able to visualize whitespace characters (particularly if we can differentiate between tabs and spaces) is helpful.

alandmoore avatar May 13 '17 20:05 alandmoore

@alandmoore

Whitespace is significant in many languages, and being able to visualize whitespace characters (particularly if we can differentiate between tabs and spaces) is helpful.

But that would look messy thou....and remember we are only removing trailing white space, which is never useful in any ways I think, but it will mess with version control thou, which is why we are removing it.

justinjk007 avatar May 13 '17 20:05 justinjk007

I think recent changes to Emacs (eglot, tree-sitter, etc) has helped make Emacs much more usable OOB. Considering repo-purpose obsolete.

Closing all issues and archiving repo. Thanks to all contributors!

josteink avatar Oct 11 '23 07:10 josteink