From 9ad1e2555ee67d4cd7dfc538f09f37b1eecc5566 Mon Sep 17 00:00:00 2001 From: Maciej Barć Date: Tue, 22 Aug 2023 15:48:26 +0200 Subject: eclass/elisp-common.eclass: add elisp-org-export-to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maciej Barć Signed-off-by: Ulrich Müller --- eclass/elisp-common.eclass | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'eclass/elisp-common.eclass') diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 03e47d931f44..ef24622d405e 100644 --- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -348,6 +348,39 @@ elisp-make-autoload-file() { eend $? "elisp-make-autoload-file: batch-update-autoloads failed" || die } +# @FUNCTION: elisp-org-export-to +# @USAGE: +# @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: -- cgit v1.2.3-65-gdbad