From 189830782f722286489071cf9cfeb55d11437330 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Thu, 5 Dec 2024 10:05:30 +0800 Subject: [PATCH] emacs30: add a patch to fix upstream bug 67916 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67916 --- ...ibit-lexical-cookie-warning-67916-30.patch | 30 +++++++++++++++++++ pkgs/applications/editors/emacs/sources.nix | 6 ++++ 2 files changed, 36 insertions(+) create mode 100644 pkgs/applications/editors/emacs/inhibit-lexical-cookie-warning-67916-30.patch diff --git a/pkgs/applications/editors/emacs/inhibit-lexical-cookie-warning-67916-30.patch b/pkgs/applications/editors/emacs/inhibit-lexical-cookie-warning-67916-30.patch new file mode 100644 index 0000000000000..c81a0d0b94b81 --- /dev/null +++ b/pkgs/applications/editors/emacs/inhibit-lexical-cookie-warning-67916-30.patch @@ -0,0 +1,30 @@ +From: Lin Jian +Bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67916 + +Inhibit lexical cookie warning for *-pkg.el files (bug#67916) + +Users may use byte-compile-error-on-warn to turn compilation warnings +into errors to make sure their Emacs lisp packages are warning-free. +Emacs bug 67916 makes that difficult because the Emacs-generated file +*-pkg.el emits a compilation warning about missing lexical cookie. + +There is an upstream patch to fix this. That patch makes Emacs also +generate the needed lexical cookie when generating *-pkg.el files. +However, that patch has stalled. + +This patch takes an easier but less accurate approach by inhibiting +lexical cookie warning for *-pkg.el files. Given that not all +*-pkg.el files are generated by Emacs, to reduce impact, this patch +also checks no-byte-compile. + +--- a/lisp/emacs-lisp/bytecomp.el ++++ b/lisp/emacs-lisp/bytecomp.el +@@ -2266,6 +2266,8 @@ See also `emacs-lisp-byte-compile-and-load'." + filename buffer-file-name)) + ;; Don't inherit lexical-binding from caller (bug#12938). + (unless (or (local-variable-p 'lexical-binding) ++ (and (string-suffix-p "-pkg.el" filename) ++ (with-current-buffer input-buffer no-byte-compile)) + bytecomp--inhibit-lexical-cookie-warning) + (let ((byte-compile-current-buffer (current-buffer))) + (displaying-byte-compile-warnings diff --git a/pkgs/applications/editors/emacs/sources.nix b/pkgs/applications/editors/emacs/sources.nix index 30b00af8da9e4..374702dc1fcb7 100644 --- a/pkgs/applications/editors/emacs/sources.nix +++ b/pkgs/applications/editors/emacs/sources.nix @@ -150,6 +150,12 @@ in variant = "mainline"; rev = "30.0.93"; hash = "sha256-lcpB4lKD3tjvCn646hUyAskxWNCQwEJ0RX/ZddRBRRU="; + patches = fetchpatch: [ + (builtins.path { + name = "inhibit-lexical-cookie-warning-67916.patch"; + path = ./inhibit-lexical-cookie-warning-67916-30.patch; + }) + ]; }); emacs28-macport = import ./make-emacs.nix (mkArgs {