(when '(not fundamental-mode))
You are not passing a function as the second arg to
add-hook. You are passing the symbol
add-hook is a function, so all of its args are evaluated before it does its thing (using their values). The value of the sexp you passed as its second arg is the symbol
delete-trailing-whitespace, because the arg to
when is a non-nil list (because you quoted it). So the
when condition is always true.
And you never invoke function
delete-trailing-whitespace; you just return the symbol that names that function.
You need to pass a function to
add-hook. Something like this:
(unless (eq major-mode 'fundamental-mode)
But are you sure that you want to do that for every possible mode other than
fundamental-mode? If not, consider checking
major-mode against a whitelist or a blacklist of modes.
And consider using
derived-mode-p to test modes - it is typically more appropriate than testing them using