Subject: [PATCH] recentf, abbrev: insert a lexical-binding cookie

From: Arsen Arsenović <[email-masked]>
Date: Wed, 9 Apr 2025 14:21:06 +0200

* lisp/recentf.el (recentf-save-file-header): Change default
header to include a lexical-binding cookie.
* lisp/abbrev.el (write-abbrev-file): Insert a lexical-binding
cookie into abbrev files.
---
This fixes a few lexical-binding warnings I noticed when updating Emacs
today.

 lisp/abbrev.el  | 3 ++-
 lisp/recentf.el | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 93eb086da7a..2868919283a 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -270,7 +270,8 @@ write-abbrev-file
       (when (unencodable-char-position (point-min) (point-max) 'utf-8)
 	(setq coding-system-for-write 'utf-8-emacs))
       (goto-char (point-min))
-      (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write))
+      (insert (format ";;-*-coding: %s; lexical-binding: t;-*-\n"
+                      coding-system-for-write))
       (write-region nil nil file nil (and (not verbose) 0)))))
 
 (defun abbrev-edit-save-to-file (file)
diff --git a/lisp/recentf.el b/lisp/recentf.el
index 172ce704d93..c58964959e8 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1316,7 +1316,8 @@ recentf-open-most-recent-file
 ;;; Save/load/cleanup the recent list
 ;;
 (defconst recentf-save-file-header
-  ";;; Automatically generated by `recentf' on %s.  -*- mode: lisp-data -*-\n"
+  ";;; Automatically generated by `recentf' on %s.  \
+-*- mode: lisp-data; lexical-binding: t; -*-\n"
   "Header to be written into the `recentf-save-file'.")
 
 (defconst recentf-save-file-coding-system
-- 
2.49.0