elisp-common.eclass: Add lexbind cookie to site-init files

This is needed for individual site-init files to be loaded, since Emacs
from Git now complains about missing lexical-binding cookies.

Drop any initial blank lines when installing site-init files in
elisp-site-file-install. Instead, insert blank lines when concatenating
the files in elisp-site-regen.

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
This commit is contained in:
Ulrich Müller 2025-04-21 13:41:47 +02:00
parent 0e818d162f
commit 3ba318e113
No known key found for this signature in database
GPG Key ID: 5188335088415E2E

View File

@ -1,4 +1,4 @@
# Copyright 1999-2024 Gentoo Authors # Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# @ECLASS: elisp-common.eclass # @ECLASS: elisp-common.eclass
@ -626,12 +626,12 @@ elisp-modules-install() {
elisp-site-file-install() { elisp-site-file-install() {
local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret
local add_header="1 { local add_header="0,/\S/ {
# Find first non-empty line # Delete any leading blank lines
:x; /^\$/ { n; bx; } /\S/! d
# Insert a header, unless we already look at one # Insert a header, unless we are already looking at one
/^;.*${PN}/I! s/^/;;; ${PN} site-lisp configuration\n\n/ /^;.*${PN}/I! \
1 s/^/\n/ i ;;; ${PN} site-lisp configuration -*-lexical-binding:t-*-\n
}" }"
[[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
@ -711,11 +711,15 @@ elisp-site-regen() {
;; DO NOT EDIT THIS FILE ;; DO NOT EDIT THIS FILE
;;; Code: ;;; Code:
EOF
# Use sed instead of cat here, since files may miss a trailing newline.
sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el || ret=$?
cat <<-EOF >>"${T}"/site-gentoo.el || ret=$?
EOF
# Concatenate all site initialisation files.
# 1{/^;/s/\s*-\*-.*-\*-//} deletes file-local-var cookies from line 1.
# /\S/,$!d deletes any leading blank lines.
# $G inserts a blank line after each file.
sed -s '1{/^;/s/\s*-\*-.*-\*-//};/\S/,$!d;$G' "${sflist[@]}" \
</dev/null >>"${T}"/site-gentoo.el || ret=$?
cat <<-EOF >>"${T}"/site-gentoo.el || ret=$?
${page} ${page}
(provide 'site-gentoo) (provide 'site-gentoo)