From ee0c4d0b14c9ece913d340fe5a074e1f63726fc6 Mon Sep 17 00:00:00 2001 From: Ulrich Müller Date: Sat, 25 Jul 2020 21:08:45 +0200 Subject: elisp-common.eclass: Support installation of dynamic modules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ulrich Müller --- eclass/elisp-common.eclass | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 6fa2bbe..0bf6c01 100644 --- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -180,6 +180,12 @@ SITELISP=/usr/share/emacs/site-lisp # Directory where packages install miscellaneous (not Lisp) files. SITEETC=/usr/share/emacs/etc +# @ECLASS-VARIABLE: EMACSMODULES +# @DESCRIPTION: +# Directory where packages install dynamically loaded modules. +# May contain a @libdir@ token which will be replaced by $(get_libdir). +EMACSMODULES=/usr/@libdir@/emacs/modules + # @ECLASS-VARIABLE: EMACS # @DESCRIPTION: # Path of Emacs executable. @@ -362,17 +368,37 @@ elisp-install() { eend $? "elisp-install: doins failed" || die } +# @FUNCTION: elisp-modules-install +# @USAGE: +# @DESCRIPTION: +# Install dynamic modules in EMACSMODULES directory. + +elisp-modules-install() { + local subdir="$1" + shift + # Don't bother inheriting multilib.eclass for get_libdir(), but + # error out in old EAPIs that don't support it natively. + [[ ${EAPI} == [45] ]] \ + && die "${ECLASS}: Dynamic modules not supported in EAPI ${EAPI}" + ebegin "Installing dynamic modules for GNU Emacs support" + ( # subshell to avoid pollution of calling environment + exeinto "${EMACSMODULES//@libdir@/$(get_libdir)}/${subdir}" + doexe "$@" + ) + eend $? "elisp-modules-install: doins failed" || die +} + # @FUNCTION: elisp-site-file-install # @USAGE: [subdirectory] # @DESCRIPTION: # Install Emacs site-init file in SITELISP directory. Automatically -# inserts a standard comment header with the name of the package (unless -# it is already present). Tokens @SITELISP@ and @SITEETC@ are replaced -# by the path to the package's subdirectory in SITELISP and SITEETC, -# respectively. +# inserts a standard comment header with the name of the package +# (unless it is already present). Tokens @SITELISP@, @SITEETC@, and +# @EMACSMODULES@ are replaced by the path to the package's subdirectory +# in SITELISP, SITEETC, and EMACSMODULES, respectively. elisp-site-file-install() { - local sf="${1##*/}" my_pn="${2:-${PN}}" ret + local sf="${1##*/}" my_pn="${2:-${PN}}" modules ret local header=";;; ${PN} site-lisp configuration" [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ @@ -381,9 +407,13 @@ elisp-site-file-install() { sf="${T}/${sf}" ebegin "Installing site initialisation file for GNU Emacs" [[ $1 = "${sf}" ]] || cp "$1" "${sf}" + [[ ${EAPI} == [45] ]] && grep -q "@EMACSMODULES@" "${sf}" \ + && die "${ECLASS}: Dynamic modules not supported in EAPI ${EAPI}" + modules=${EMACSMODULES//@libdir@/$(get_libdir)} sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ - -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}" + -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g" \ + -e "s:@EMACSMODULES@:${EPREFIX}${modules}/${my_pn}:g;\$q" "${sf}" ( # subshell to avoid pollution of calling environment insinto "${SITELISP}/site-gentoo.d" doins "${sf}" -- cgit v1.2.3-65-gdbad