
Thomas Schilling wrote:
On 2 aug 2007, at 12.10, Simon Marlow wrote:
While we're on emacs... I know I can colour trailing whitespace differently, but that's just annoying. What I want is: on lines that I edit, remove the trailing whitespace (and if I undo the edit, put the whitespace back too). Is there something that does that? I couldn't find it.
The simplest thing I can think of, is to not remove whitespace at all, but to only remove it when you're saving the file. I know that some modes use such a save hook. It also wouldn't modify the actual file (ie, don't remove the whitespace until you save the file for the first time), as long as you edit it. The only time the spaces would be removed permanently were if you save the file, close the buffer, and then re-open the file.
If I can come up with a simple solution, I'll let you know.
I don't actually want it done on the whole file, which is why I asked for the behaviour only on lines that I edit. The idea is to be revision-control-friendly by not introducing unrelated formatting changes. You could start by removing all the trailing whitespace in all the sources in the repository, but I think that's unnecessary. Also I don't want to be forced to do this everywhere. Cheers, Simon