From bb80ec4def3ec8f0930f1d9f23f5bdf427ca72ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Thu, 8 Nov 2018 13:19:42 -0500 Subject: 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. --- lisp/init-editing-utils.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/init-editing-utils.el b/lisp/init-editing-utils.el index ff7bc39..292fa1d 100644 --- a/lisp/init-editing-utils.el +++ b/lisp/init-editing-utils.el @@ -6,8 +6,9 @@ ;; Delete-trailing-whitespace-when-saving-except-certain-modes (add-hook 'before-save-hook - (when '(not diff-mode)) - 'delete-trailing-whitespace) + (lambda () + (unless (eq major-mode 'diff-mode) + (delete-trailing-whitespace)))) ;;---------------------------------------------------------------------------- ;; Automatic pairs open symbols (, {, [... ;; Disable for default. -- cgit v1.2.3