summaryrefslogtreecommitdiff
path: root/eclass/elisp-common.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-08-26 09:56:45 +0100
committerV3n3RiX <venerix@koprulu.sector>2023-08-26 09:56:45 +0100
commitf3471ff11210507b38c09f0e57df1bd601f629a5 (patch)
tree9931bc74efae95f78cd0270fde107c779d2dd482 /eclass/elisp-common.eclass
parent5e5fb5c6d1e0af4b12dbee7de7d095df902ce2b6 (diff)
gentoo auto-resync : 26:08:2023 - 09:56:44
Diffstat (limited to 'eclass/elisp-common.eclass')
-rw-r--r--eclass/elisp-common.eclass95
1 files changed, 69 insertions, 26 deletions
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
index 1958b4a07e18..a40c9f63007d 100644
--- a/eclass/elisp-common.eclass
+++ b/eclass/elisp-common.eclass
@@ -348,17 +348,51 @@ elisp-make-autoload-file() {
eend $? "elisp-make-autoload-file: batch-update-autoloads failed" || die
}
+# @FUNCTION: elisp-org-export-to
+# @USAGE: <export file type> <Org file path>
+# @DESCRIPTION:
+# Use Emacs Org "export-to" functions to convert a given Org file to a
+# picked format.
+#
+# Example:
+# @CODE
+# elisp-org-export-to texinfo README.org
+# mv README.texi ${PN}.texi || die
+# @CODE
+
+elisp-org-export-to() {
+ local export_format="${1}"
+ local org_file_path="${2}"
+
+ local export_group
+ case ${export_format} in
+ info) export_group=texinfo ;; # Straight to ".info".
+ markdown) export_group=md ;;
+ pdf) export_group=latex ;;
+ *) export_group=${export_format} ;;
+ esac
+
+ # export_format = texinfo => org-texinfo-export-to-texinfo
+ # export_format = pdf => org-latex-export-to-pdf
+
+ local export_function=org-${export_group}-export-to-${export_format}
+
+ ${EMACS} ${EMACSFLAGS} "${org_file_path}" -f "${export_function}" \
+ || die "Org export to ${export_format} failed"
+}
+
# @FUNCTION: elisp-test-buttercup
# @USAGE: [test-subdirectory] [test-runner-opts] ...
# @DESCRIPTION:
# Run ELisp package tests using the "buttercup" test runner.
#
-# The option "test-subdirectory" may be given any number of times, it should
-# be given as though it was passed to Emacs or the test tool, not as a string.
+# The option "test-subdirectory" may be given any number of times,
+# it should be given as though it was passed to Emacs or the test tool,
+# not as a string.
#
# The options "test-subdirectory" and "test-runner-opts" are optional,
-# but if "test-runner-opts" needs to be provided also "test-subdirectory" has
-# to be specified.
+# but if "test-runner-opts" needs to be provided also "test-subdirectory"
+# has to be specified.
elisp-test-buttercup() {
debug-print-function ${FUNCNAME} "$@"
@@ -382,12 +416,13 @@ elisp-test-buttercup() {
# @DESCRIPTION:
# Run ELisp package tests using the "ert-runner" test runner.
#
-# The option "test-subdirectory" may be given any number of times, it should
-# be given as though it was passed to Emacs or the test tool, not as a string.
+# The option "test-subdirectory" may be given any number of times,
+# it should be given as though it was passed to Emacs or the test tool,
+# not as a string.
#
# The options "test-subdirectory" and "test-runner-opts" are optional,
-# but if "test-runner-opts" needs to be provided also "test-subdirectory" has
-# to be specified.
+# but if "test-runner-opts" needs to be provided also "test-subdirectory"
+# has to be specified.
elisp-test-ert-runner() {
debug-print-function ${FUNCNAME} "$@"
@@ -412,12 +447,13 @@ elisp-test-ert-runner() {
# @DESCRIPTION:
# Run ELisp package tests using "ert", the Emacs's built-in test runner.
#
-# The option "test-subdirectory" may be given any number of times, it should
-# be given as though it was passed to Emacs or the test tool, not as a string.
+# The option "test-subdirectory" may be given any number of times,
+# it should be given as though it was passed to Emacs or the test tool,
+# not as a string.
#
# The options "test-subdirectory" and "test-runner-opts" are optional,
-# but if "test-runner-opts" needs to be provided also "test-subdirectory" has
-# to be specified.
+# but if "test-runner-opts" needs to be provided also "test-subdirectory"
+# has to be specified.
elisp-test-ert() {
debug-print-function ${FUNCNAME} "$@"
@@ -449,8 +485,8 @@ elisp-test-ert() {
# @FUNCTION: elisp-enable-tests
# @USAGE: [--optional] <test-runner> [test-runner-options] ...
# @DESCRIPTION:
-# Set up IUSE, RESTRICT, BDEPEND and test runner function for running tests
-# with the specified test runner.
+# Set up IUSE, RESTRICT, BDEPEND and test runner function for running
+# tests with the specified test runner.
#
# The test-runner argument must be one of:
#
@@ -460,18 +496,19 @@ elisp-test-ert() {
#
# - ert: for built-in GNU Emacs test utility
#
-# If the "--optional" flag is passed (before specifying the test runner),
-# then it is assumed that the ELisp package is a part of some project that
-# optionally enables GNU Emacs support.
-# This will correctly set up the test and Emacs dependencies.
+# If the "--optional" flag is passed (before specifying the test
+# runner), then it is assumed that the ELisp package is a part of some
+# some project that optionally enables GNU Emacs support. This will
+# correctly set up the test and Emacs dependencies.
#
-# Notice that the fist option passed to the "test-runner" is the directory
-# and the rest are miscellaneous options applicable to that given runner.
+# Notice that the fist option passed to the "test-runner" is the
+# directory and the rest are miscellaneous options applicable to that
+# given runner.
#
-# This function has to be called post inherit, specifically after "IUSE",
-# "RESTRICT" and "BDEPEND" variables are assigned.
-# It is advised to place this call right before (re)defining a given ebuild's
-# phases.
+# This function has to be called post inherit, specifically after
+# "IUSE", "RESTRICT" and "BDEPEND" variables are assigned.
+# It is advised to place this call right before (re)defining a given
+# ebuild's phases.
#
# Example:
# @CODE
@@ -590,7 +627,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 +642,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}"