how would I figure this out?
I added delete-trailing-whitespace to the before-save-hook in my c-mode-common-hook, but it loo
No, the variable before-save-hook is not naturally buffer local. The variable's documentation does not say it's buffer local or say it will automatically become buffer local when set.
If you want to add a buffer-local hook to it, the correct way to do this is just to use the optional LOCAL parameter of the standard add-hook function:
(add-hook 'before-save-hook 'foo nil t)
The add-hook documentation says:
The optional fourth argument, LOCAL, if non-nil, says to modify the hook's buffer-local value rather than its global value. This makes the hook buffer-local, and it makes t a member of the buffer-local value. That acts as a flag to run the hook functions of the global value as well as in the local value.
The selected answer to add it to local-write-file-hooks is wrong, I believe. If you look at the documentation for that function, on emacs 24.3, it says the variable is obsolete since 22.1, and you should use write-file-functions. And if you lookup the documentation of write-file-functions, it describes more complex behavior and says at the end that "To perform various checks or updates before the buffer is saved, use `before-save-hook'".