Subject: Re: bug#79199: [PATCH] Add 'lexical-binding' cookie in nnrss output

From: Manuel Giraud <[email-masked]>
Date: Sun, 10 Aug 2025 15:20:18 +0200

Eli Zaretskii <[email-masked]> writes:

>> Cc: Shenghuo Zhu <[email-masked]>, [email-masked]
>> From: Manuel Giraud <[email-masked]>
>> Date: Sun, 10 Aug 2025 12:33:32 +0200
>> 
>> Robert Pluim <[email-masked]> writes:
>> 
>> > stick a
>> >
>> >              (let ((warning-inhibit-types '((files missing-lexbind-cookie))))
>> >
>> > around the loading of the file.
>> 
>> Thanks.  Do you know if we need to have both the fix at write time and
>> the fix at read time?  Because FWIW, with only the fix at write time I
>> don't see any warnings anymore.
>
> The fix at read time is for when Emacs loads a file written by an
> older version of Emacs.  If that could happen (e.g., when Emacs 31 is
> first run after being installed), then we need also the read-time fix.

Ok.  Here is, I think, a complete version.
>From 62fa39f2cc9b679e36ffab7f31a81508607de771 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Fri, 8 Aug 2025 17:53:01 +0200
Subject: [PATCH] Handle 'lexical-binding' cookie in nnrss output

* lisp/gnus/nnrss.el (nnrss-save-server-data)
(nnrss-save-group-data): Add a 'lexical-binding' cookie.
* lisp/gnus/nnrss.el (nnrss-read-server-data)
(nnrss-read-group-data): Allow missing 'lexical-binding' cookie.
---
 lisp/gnus/nnrss.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index e166fa8424f..60282167409 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -496,7 +496,8 @@ nnrss-normalize-date
 (defun nnrss-read-server-data (server)
   (setq nnrss-server-data nil)
   (let ((file (nnrss-make-filename "nnrss" server))
-	(file-name-coding-system nnmail-pathname-coding-system))
+        (file-name-coding-system nnmail-pathname-coding-system)
+        (warning-inhibit-types '((files missing-lexbind-cookie))))
     (when (file-exists-p file)
       (load file nil t t))))
 
@@ -505,7 +506,7 @@ nnrss-save-server-data
   (let ((coding-system-for-write nnrss-file-coding-system)
 	(file-name-coding-system nnmail-pathname-coding-system))
     (with-temp-file (nnrss-make-filename "nnrss" server)
-      (insert (format ";; -*- coding: %s; -*-\n"
+      (insert (format ";; -*- coding: %s; lexical-binding:t -*-\n"
 		      nnrss-file-coding-system))
       (gnus-prin1 `(setq nnrss-group-alist ',nnrss-group-alist))
       (insert "\n")
@@ -520,7 +521,8 @@ nnrss-read-group-data
     (setq nnrss-group-max (or (cadr pair) 0))
     (setq nnrss-group-min (+ nnrss-group-max 1)))
   (let ((file (nnrss-make-filename group server))
-	(file-name-coding-system nnmail-pathname-coding-system))
+        (file-name-coding-system nnmail-pathname-coding-system)
+        (warning-inhibit-types '((files missing-lexbind-cookie))))
     (when (file-exists-p file)
       (load file nil t t)
       (dolist (e nnrss-group-data)
@@ -535,7 +537,7 @@ nnrss-save-group-data
   (let ((coding-system-for-write nnrss-file-coding-system)
 	(file-name-coding-system nnmail-pathname-coding-system))
     (with-temp-file (nnrss-make-filename group server)
-      (insert (format ";; -*- coding: %s; -*-\n"
+      (insert (format ";; -*- coding: %s; lexical-binding:t -*-\n"
 		      nnrss-file-coding-system))
       (gnus-prin1 `(setq nnrss-group-data ',nnrss-group-data)))))
 
-- 
2.50.1

-- 
Manuel Giraud