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

Doesn't remove whitespaces on save #21

Open
EDmitry opened this issue May 11, 2014 · 5 comments
Open

Doesn't remove whitespaces on save #21

EDmitry opened this issue May 11, 2014 · 5 comments

Comments

@EDmitry
Copy link

EDmitry commented May 11, 2014

I have the following in my .emacs:

(add-to-list 'load-path "~/.emacs.d/")
(require 'ethan-wspace)
(global-ethan-wspace-mode 1)

Do I understand that when I open the file then create some new line consisting of only spaces (which ethan-wspace highlights) then hit C-x C-s and whitespaces should be removed? This doesn't happen for some reason.

@dgutov
Copy link
Contributor

dgutov commented May 11, 2014

AFAICT, the whitespace is removed before saving, it just doesn't look that way. See #16.

@twmr
Copy link

twmr commented Jul 17, 2014

I have the same problem. Even ethan-wspace-clean-all-modes does not work, i.e., it does not modify the buffer.

I'm using emacs-24.4-dev (from the git mirror) and the git version of ethan-wspace.

Reproduced the issue with

emacs -Q -L lisp --eval="(require 'ethan-wspace) (global-ethan-wspace-mode 1)"

@glasserc
Copy link
Owner

Hi! Sorry for the delay in responding. I'm confused about what exactly the problem is. If whitespace of any kind is being highlit, that means it's not being cleaned, for fear of introducing spurious whitespace changes. A quick way to tell whether ethan-wspace is going to try to clean a kind of whitespace is to look for the modeline "lighter", which should look like "ew:mnlt". Any letters that are uppercase indicate a kind of whitespace that won't be cleaned. If you click the letter, they'll toggle between highlighting and clean-before-save.

The function ethan-wspace-clean-all-modes is pretty confusing because it doesn't actually clean anything, just sets everything to clean-before-save. You still have to save before whitespace gets cleaned. Issues #23 and #24 are about this very confusion and I'm hoping to have time to document a little more thoroughly/rename some functions to make this be clearer. Recent ethan-wspace has a function called ethan-wspace-clean-all, which cleans all errors as well as switching to clean-before-save.

Does this address your questions? If not, can you elaborate on what isn't working?

@twmr
Copy link

twmr commented Jul 19, 2014

Not really.

The behavior of ethan-wspace-clean-all-modes is indeed confusing. Thx for mentioning ethan-wspace-clean-all, it works a bit better than ethan-wspace-clean-all-modes, except that when I'm on a line with whitespace issues when saving the buffer to a file. In this case the whitespace on this line does not get cleaned.

Steps to reproduce:

  • open a new file
  • enable ethan-wspace-mode
  • enter text with whitespace at EOL.
  • when the point is over ws @ EOL save the buffer
  • whitespace issues are still present. (Bug?, Note that ws issues get fixed while saving the buffer when point is not over ws @ EOL.)
  • call ethan-wspace-clean-all (point is still over ws @ EOL)
  • this fixed the ws issues
  • add new ws issues
  • save the buffer (point is over a ws-clean line)
  • this fixed the newly added ws issues.
  • again add new ws issues @ EOL
  • save the buffer (point is over ws @ EOL)
  • ws issues still present.

@glasserc
Copy link
Owner

I believe what you are reporting is a feature, not a bug. See #16. Try running cat -A on the file to show where the true EOL is.

To be honest I had forgotten that this feature existed and when I rediscovered it, I added a paragraph to the README at the end of the section "What does it do?" I admit that it's a bit confusing that the buffer appears to be "clean" although the contents of the buffer don't match the contents of the file. However, I think that it would be worse to have the file "save" but still be dirty. So I'm not really sure what to do about it except document it better..

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

4 participants