···1+From: Lin Jian <me@linj.tech>
2+Bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67916
3+4+Inhibit lexical cookie warning for *-pkg.el files (bug#67916)
5+6+Users may use byte-compile-error-on-warn to turn compilation warnings
7+into errors to make sure their Emacs lisp packages are warning-free.
8+Emacs bug 67916 makes that difficult because the Emacs-generated file
9+*-pkg.el emits a compilation warning about missing lexical cookie.
10+11+There is an upstream patch to fix this. That patch makes Emacs also
12+generate the needed lexical cookie when generating *-pkg.el files.
13+However, that patch has stalled.
14+15+This patch takes an easier but less accurate approach by inhibiting
16+lexical cookie warning for *-pkg.el files. Given that not all
17+*-pkg.el files are generated by Emacs, to reduce impact, this patch
18+also checks no-byte-compile.
19+20+--- a/lisp/emacs-lisp/bytecomp.el
21++++ b/lisp/emacs-lisp/bytecomp.el
22+@@ -2266,6 +2266,8 @@ See also `emacs-lisp-byte-compile-and-load'."
23+ filename buffer-file-name))
24+ ;; Don't inherit lexical-binding from caller (bug#12938).
25+ (unless (or (local-variable-p 'lexical-binding)
26++ (and (string-suffix-p "-pkg.el" filename)
27++ (with-current-buffer input-buffer no-byte-compile))
28+ bytecomp--inhibit-lexical-cookie-warning)
29+ (let ((byte-compile-current-buffer (current-buffer)))
30+ (displaying-byte-compile-warnings