From ea7361c10c4deb13c25fefec705a05403506b860 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index e929c02..22491a2 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2311,6 +2311,10 @@ 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 (or (string-suffix-p "-hook" (symbol-name sym)) + (string-suffix-p "-functions" (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