[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cda5155c618: Inhibit flymake lexical cookie warning in *scratch*
From: |
Mattias Engdegård |
Subject: |
master cda5155c618: Inhibit flymake lexical cookie warning in *scratch* (bug#70068) |
Date: |
Tue, 9 Apr 2024 04:57:35 -0400 (EDT) |
branch: master
commit cda5155c618d774810ce5e044efe1101846054ac
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
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.
---
lisp/emacs-lisp/bytecomp.el | 5 ++++-
lisp/progmodes/elisp-mode.el | 11 ++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 5cff86784f0..fb3278c08ab 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -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
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 8a713bd19a2..9b4c3f994cd 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2169,6 +2169,8 @@ directory of the buffer being compiled, and nothing
else.")
(dolist (path x t) (unless (stringp path)
(throw 'tag nil)))))))
+(defvar bytecomp--inhibit-lexical-cookie-warning)
+
;;;###autoload
(defun elisp-flymake-byte-compile (report-fn &rest _args)
"A Flymake backend for elisp byte compilation.
@@ -2184,7 +2186,13 @@ current buffer state and calls REPORT-FN when done."
(save-restriction
(widen)
(write-region (point-min) (point-max) temp-file nil 'nomessage))
- (let* ((output-buffer (generate-new-buffer "
*elisp-flymake-byte-compile*")))
+ (let* ((output-buffer (generate-new-buffer "
*elisp-flymake-byte-compile*"))
+ ;; Hack: suppress warning about missing lexical cookie in
+ ;; *scratch* buffers.
+ (warning-suppression-opt
+ (and (derived-mode-p 'lisp-interaction-mode)
+ '("--eval"
+ "(setq bytecomp--inhibit-lexical-cookie-warning t)"))))
(setq
elisp-flymake--byte-compile-process
(make-process
@@ -2196,6 +2204,7 @@ current buffer state and calls REPORT-FN when done."
;; "--eval" "(setq load-prefer-newer t)" ; for testing
,@(mapcan (lambda (path) (list "-L" path))
elisp-flymake-byte-compile-load-path)
+ ,@warning-suppression-opt
"-f" "elisp-flymake--batch-compile-for-flymake"
,temp-file)
:connection-type 'pipe
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master cda5155c618: Inhibit flymake lexical cookie warning in *scratch* (bug#70068),
Mattias Engdegård <=