diff options
author | Ulrich Müller <ulm@gentoo.org> | 2023-08-21 20:33:16 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2023-08-26 08:51:05 +0200 |
commit | 6b71af98697861a9ad1934195ea4ab3c2b93bba8 (patch) | |
tree | 965175a6bdc33560421aab195c553fccd552b30e /eclass/elisp-common.eclass | |
parent | sys-cluster/glusterfs: Stabilize 11.0-r1 ppc64, #913033 (diff) | |
download | gentoo-6b71af98697861a9ad1934195ea4ab3c2b93bba8.tar.gz gentoo-6b71af98697861a9ad1934195ea4ab3c2b93bba8.tar.bz2 gentoo-6b71af98697861a9ad1934195ea4ab3c2b93bba8.zip |
elisp-common.eclass: Document sed script in elisp-site-file-install
Even though it is a simple one-liner, some people find it difficult
to read.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'eclass/elisp-common.eclass')
-rw-r--r-- | eclass/elisp-common.eclass | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 1958b4a07e18..03e47d931f44 100644 --- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -590,7 +590,13 @@ elisp-modules-install() { elisp-site-file-install() { local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret - local header=";;; ${PN} site-lisp configuration" + 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/ + }" [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ || ewarn "elisp-site-file-install: bad name of site-init file" @@ -599,7 +605,7 @@ elisp-site-file-install() { ebegin "Installing site initialisation file for GNU Emacs" [[ $1 == "${sf}" ]] || cp "$1" "${sf}" modules=${EMACSMODULES//@libdir@/$(get_libdir)} - sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ + sed -i -e "${add_header}" \ -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g" \ -e "s:@EMACSMODULES@:${EPREFIX}${modules}/${my_pn}:g;\$q" "${sf}" |