From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1D881158009 for ; Thu, 29 Jun 2023 17:47:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8F125E077C; Thu, 29 Jun 2023 17:47:21 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5D3ACE0391 for ; Thu, 29 Jun 2023 17:47:21 +0000 (UTC) From: =?UTF-8?q?Ulrich=20M=C3=BCller?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Ulrich=20M=C3=BCller?= Subject: [gentoo-dev] [PATCH 1/2] elisp-common.eclass: New function elisp-make-site-file Date: Thu, 29 Jun 2023 19:46:59 +0200 Message-ID: <20230629174708.15232-1-ulm@gentoo.org> X-Mailer: git-send-email 2.41.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: f02034d6-70a8-4ad2-8a8b-bfbea7aea335 X-Archives-Hash: 81e13bbd1b3bf16a3fe1103d1b979561 This creates and installs a site-init file for the package. The default case will add the package's SITELISP subdirectory to Emacs' load-path. This allows to remove all trivial site-init files (consisting only of a load-path line). More complicated cases can be handled by providing additional arguments, which are appended as lines to the site-init file. Signed-off-by: Ulrich Müller --- eclass/elisp-common.eclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 1f60d3c337b9..ff1b2d0da0f3 100644 --- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -132,6 +132,17 @@ # "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give # the differing name as second argument. # +# For the simple case that only the package's subdirectory needs to be +# added to the load-path, function elisp-make-site-file() will create +# and install a site-init file that does just that: +# +# @CODE +# elisp-make-site-file "${SITEFILE}" +# @CODE +# +# Again, this must be called in src_install(). See the function's +# documentation for more details on its usage. +# # @SUBSECTION pkg_setup() usage: # # If your ebuild uses the elisp-compile eclass function to compile @@ -601,6 +612,30 @@ elisp-site-file-install() { eend ${ret} "elisp-site-file-install: doins failed" || die } +# @FUNCTION: elisp-make-site-file +# @USAGE: [subdirectory] [line]... +# @DESCRIPTION: +# Create and install a site-init file for the package. By default, +# this will add the package's SITELISP subdirectory to Emacs' load-path: +# +# @CODE +# (add-to-list 'load-path "@SITELISP@") +# @CODE +# +# Additional arguments are appended as lines to the destination file. +# Any @SITELISP@, @SITEETC@, and @EMACSMODULES@ tokens in these +# arguments are replaced, as described for elisp-site-file-install. + +elisp-make-site-file() { + [[ $1 == [0-9][0-9]*-gentoo.el ]] \ + || die "elisp-make-site-file: bad name of site-init file" + + local f="${T}/$1" my_pn="${2:-${PN}}" + shift; shift + printf "%s\n" "(add-to-list 'load-path \"@SITELISP@\")" "$@" >"${f}" || die + elisp-site-file-install "${f}" "${my_pn}" +} + # @FUNCTION: elisp-site-regen # @DESCRIPTION: # Regenerate the site-gentoo.el file, based on packages' site -- 2.41.0