Try to be smarter when it comes to mode-require-final-newline and require-final-newline. In either case, just turn off require-final-newline and work as expected, since the user has already demonstrated by installing ethan-wspace and invoking the mode that they want ethan-wspace to work correctly.
Remaining problem: the eol cleaner runs *after* the trailing newline cleaner. So if you have a file like: blah blah <newline> <newline><trailing whitespace> <newline> <newline><trailing whitespace> then with this patch, you have to save *twice* to fully clean the file. Unfortunately right now the order cleaners are run in is determined by the order they are defined in the file, which is pretty obscure.
Closes: #15 This commit does three things: - Adds a new :clean-fixup function to the general cleaner framework, which is called from the after-save hook. - Defines a :clean-fixup function for eol whitespace, which restores any whitespace immediately preceding point. - Defines a :clean-fixup function for many-nls-eof whitespace, which restores newlines at the end of the file if this is necessary to preserve the position of point. This seems to work great EXCEPT that if at the end of your file you have in order: (a) several newlines, (b) several horizontal whitespace characters, (c) point -- then the newlines, but not the horizontal whitespace, will disappear on save. I'm not sure what the correct fix for this is, because it appears to reflect a more fundamental bug in ethan-wspace. The problem is that the eol whitespace cleaner also cleans extraneous eof newlines. E.g., add several newlines at the end of a file, make sure your modeline says "ew:Mnlt", and then save. The newlines will be cleaned, even though trailing newlines are in highlight-don't-clean mode. But my fixup code assumes that the eol cleaner only modifies individual lines. So what causes the bug in this commit is: first the many-nls-eof cleaner runs, and does nothing. Then the eol cleaner runs, and deletes not just the trailing whitespace on the current line, but all the preceding blank lines. Then, my fixup code runs, and re-inserts the trailing whitespace, but not the trailing blank lines. Option A ("correct"): fix the eol cleaner so it never deletes whole lines. Also make sure that it runs before the eof cleaners, because it might change where the eof is. Now the code in this commit will magically start working. Option B ("expedient"): add an explicit workaround to the eol fixup code that checks for this situation explicitly, and re-adds newlines in this case. Thoughts?
It broke c-mode from Emacs master
Marking an existing face as an alias is not exactly documented AFAIK, but works fine for me. The replaced code was invoked from window-configuration-change-hook, which apparently sometimes runs when the faces subsystem hasn't yet been initialized. Refs #4