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.
This commit is contained in:
Jesús 2018-11-08 13:19:42 -05:00
parent cf4c6d84fa
commit bb80ec4def
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

View File

@ -6,8 +6,9 @@
;; Delete-trailing-whitespace-when-saving-except-certain-modes ;; Delete-trailing-whitespace-when-saving-except-certain-modes
(add-hook 'before-save-hook (add-hook 'before-save-hook
(when '(not diff-mode)) (lambda ()
'delete-trailing-whitespace) (unless (eq major-mode 'diff-mode)
(delete-trailing-whitespace))))
;;---------------------------------------------------------------------------- ;;----------------------------------------------------------------------------
;; Automatic pairs open symbols (, {, [... ;; Automatic pairs open symbols (, {, [...
;; Disable for default. ;; Disable for default.