From: Glenn Morris Date: Mon, 12 Mar 2018 18:29:01 +0000 (-0700) Subject: Make compiler warn about use of obsolete hooks X-Git-Tag: emacs-27.0.90~5506 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8048caab1d4125991b475be0ff8052f319221174;p=emacs.git Make compiler warn about use of obsolete hooks * lisp/emacs-lisp/bytecomp.el (byte-compile-form): Warn about using obsolete hooks. --- diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 2a986f6cbbc..b3ea9300b01 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3119,6 +3119,11 @@ for symbols generated by the byte compiler itself." (when (assq var byte-compile-lexical-variables) (byte-compile-report-error (format-message "%s cannot use lexical var `%s'" fn var)))))) + ;; Warn about using obsolete hooks. + (if (memq fn '(add-hook remove-hook)) + (let ((hook (car-safe (cdr form)))) + (if (eq (car-safe hook) 'quote) + (byte-compile-check-variable (cadr hook) nil)))) (when (and (byte-compile-warning-enabled-p 'suspicious) (macroexp--const-symbol-p fn)) (byte-compile-warn "`%s' called as a function" fn))