how would I figure this out?
I added delete-trailing-whitespace to the before-save-hook in my c-mode-common-hook, but it looks like delete-trailing-whitespace is getting called for every file, not just buffers using c-mode and derivatives.
Can I make the before-save-hook buffer local?
Add it to
write-contents-functionsinstead:As the Emacs Lisp Reference Manual explains:
This works properly for me in Emacs 24.2.1 (i.e., it deletes all trailing whitespace from C files but preserves trailing whitespace in all other file types).