Trimming trailing whitespace works fine on all non-JS files. I've got these lines in my .emacs:
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-hook 'before-save-hook 'whitespace-cleanup)
I've also used M-x customize-group <enter> js2-mode
to set:
Js2 Cleanup Whitespace: [Hide Value] [Toggle] on (non-nil)
[State]: SAVED and set.
Non-nil to invoke `delete-trailing-whitespace' before saves.
But it still doesn't trim whitespace on saves! What am I missing?
Edited to add: in response to Drew's suggestions,
- Running delete-trailing whitespace manually on the file does work.
- Still doesn't work without whitespace cleanup, which isn't surprising because...
- delete-trailing-whitespace doesn't seem to be called on saves.
- Neither does basic-save-buffer.
I'm not sure how to investigate how js2-mode is intercepting/preventing the before-save-hooks from being triggered.