* [gentoo-dev] [PATCH] elisp-common.eclass: Add lexbind cookie to site-init files
@ 2025-04-21 16:57 Ulrich Müller
2025-04-22 17:59 ` [gentoo-dev] [PATCH v2] " Ulrich Müller
0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Müller @ 2025-04-21 16:57 UTC (permalink / raw
To: gentoo-dev; +Cc: Ulrich Müller
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>
---
eclass/elisp-common.eclass | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
index 117544e94b35..b0cbd36bb621 100644
--- a/eclass/elisp-common.eclass
+++ b/eclass/elisp-common.eclass
@@ -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
# @ECLASS: elisp-common.eclass
@@ -627,11 +627,11 @@ elisp-modules-install() {
elisp-site-file-install() {
local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret
local add_header="1 {
- # Find first non-empty line
- :x; /^\$/ { n; bx; }
+ # Delete any leading blank lines
+ :x; /\S/! { N; s/.*\n//; bx; }
# Insert a header, unless we already look at one
- /^;.*${PN}/I! s/^/;;; ${PN} site-lisp configuration\n\n/
- 1 s/^/\n/
+ /^;.*${PN}/I! \
+ s/^/;;; ${PN} site-lisp configuration -*-lexical-binding:t-*-\n\n/
}"
[[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
@@ -711,11 +711,15 @@ elisp-site-regen() {
;; DO NOT EDIT THIS FILE
;;; 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=$?
+ # Concatenate all site initialisation files.
+ # /^;/s/\s*-\*-.*// deletes file-local-var cookies from comment lines.
+ # /\S/,$!d deletes any initial blank lines.
+ # $G inserts a blank line after each file.
+ sed -s '/^;/s/\s*-\*-.*//;/\S/,$!d;$G' "${sflist[@]}" </dev/null \
+ >>"${T}"/site-gentoo.el || ret=$?
cat <<-EOF >>"${T}"/site-gentoo.el || ret=$?
-
${page}
(provide 'site-gentoo)
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH v2] elisp-common.eclass: Add lexbind cookie to site-init files
2025-04-21 16:57 [gentoo-dev] [PATCH] elisp-common.eclass: Add lexbind cookie to site-init files Ulrich Müller
@ 2025-04-22 17:59 ` Ulrich Müller
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Müller @ 2025-04-22 17:59 UTC (permalink / raw
To: gentoo-dev; +Cc: Ulrich Müller
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>
---
eclass/elisp-common.eclass | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
index 117544e94b35..654b302bb39a 100644
--- a/eclass/elisp-common.eclass
+++ b/eclass/elisp-common.eclass
@@ -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
# @ECLASS: elisp-common.eclass
@@ -626,12 +626,12 @@ elisp-modules-install() {
elisp-site-file-install() {
local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret
- local add_header="1 {
- # Find first non-empty line
- :x; /^\$/ { n; bx; }
- # Insert a header, unless we already look at one
- /^;.*${PN}/I! s/^/;;; ${PN} site-lisp configuration\n\n/
- 1 s/^/\n/
+ local add_header="0,/\S/ {
+ # Delete any leading blank lines
+ /\S/! d
+ # Insert a header, unless we are already looking at one
+ /^;.*${PN}/I! \
+ i ;;; ${PN} site-lisp configuration -*-lexical-binding:t-*-\n
}"
[[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
@@ -711,11 +711,15 @@ elisp-site-regen() {
;; DO NOT EDIT THIS FILE
;;; 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=$?
+ # 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}
(provide 'site-gentoo)
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-22 18:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 16:57 [gentoo-dev] [PATCH] elisp-common.eclass: Add lexbind cookie to site-init files Ulrich Müller
2025-04-22 17:59 ` [gentoo-dev] [PATCH v2] " Ulrich Müller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox