Inhibit flymake lexical cookie warning in *scratch* (bug#70068)

Add a hack to prevent flymake from complaining about a missing lexical
cookie when enabled in *scratch*.

* lisp/emacs-lisp/bytecomp.el
(bytecomp--inhibit-lexical-cookie-warning): New variable.
(byte-compile-file): Use it to gate the warning.
* lisp/progmodes/elisp-mode.el (elisp-flymake-byte-compile):
Set the inhibitor when spawning a check in lisp-interaction-mode.
This commit is contained in:
Mattias Engdegård 2024-04-08 19:07:19 +02:00
parent 2c6eb49fa2
commit cda5155c61
2 changed files with 14 additions and 2 deletions

View file

@ -2149,6 +2149,8 @@ If compilation is needed, this functions returns the result of
(cons tempfile target-file))
(rename-file tempfile target-file t)))))
(defvar bytecomp--inhibit-lexical-cookie-warning nil)
;;;###autoload
(defun byte-compile-file (filename &optional load)
"Compile a file of Lisp code named FILENAME into a file of byte code.
@ -2234,7 +2236,8 @@ See also `emacs-lisp-byte-compile-and-load'."
(setq buffer-read-only nil
filename buffer-file-name))
;; Don't inherit lexical-binding from caller (bug#12938).
(unless (local-variable-p 'lexical-binding)
(unless (or (local-variable-p 'lexical-binding)
bytecomp--inhibit-lexical-cookie-warning)
(let ((byte-compile-current-buffer (current-buffer)))
(displaying-byte-compile-warnings
(byte-compile-warn-x