From 8aad74d2cb12a7afd6067b8737894c3a4b905a20 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 5 Mar 2015 21:06:07 +0100 Subject: [PATCH] Warn if a hook variable is given a non-nil init form --- lisp/emacs-lisp/bytecomp.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e929c02..b9db322 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2311,6 +2311,9 @@ list that represents a doc string reference. (defun byte-compile-file-form-defvar (form) (let ((sym (nth 1 form))) (byte-compile--declare-var sym) + (and (string-suffix-p "-hook" (symbol-name sym)) + (nth 2 form) + (byte-compile-warn "hook variable `%s' has non-nil init value" sym)) (if (eq (car form) 'defconst) (push sym byte-compile-const-variables))) (if (and (null (cddr form)) ;No `value' provided. -- 2.2.0.rc0.207.ga3a616c