summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorChristian Faulhammer <fauli@gentoo.org>2007-07-02 06:19:18 +0000
committerChristian Faulhammer <fauli@gentoo.org>2007-07-02 06:19:18 +0000
commit81729abe96c40491483c690016a3e612601019b1 (patch)
treec7d963c29a932fe7cee5b425193268594c0e2587 /eclass
parentAdding Changelog which I missed. (diff)
downloadhistorical-81729abe96c40491483c690016a3e612601019b1.tar.gz
historical-81729abe96c40491483c690016a3e612601019b1.tar.bz2
historical-81729abe96c40491483c690016a3e612601019b1.zip
elisp.eclass:
* Depend on Emacs by NEED_EMACS=<version> before inherit * DOCS variable is used in src_install() to give a number of documentation files * Documented some missing parts * Some code clean-up elisp-common: * elisp-emacs-version() to determine Emacs' current major version number * site-gentoo.el is only regenerated if there was actually a change, thus preventing unecessary output on postrm or postinst * now every action is commented with an einfo output * Documented some missing parts * Some code clean-up
Diffstat (limited to 'eclass')
-rw-r--r--eclass/elisp-common.eclass115
-rw-r--r--eclass/elisp.eclass44
2 files changed, 110 insertions, 49 deletions
diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
index afc1e499ada9..d034fde7659d 100644
--- a/eclass/elisp-common.eclass
+++ b/eclass/elisp-common.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.21 2007/05/26 08:34:08 ulm Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.22 2007/07/02 06:19:18 opfer Exp $
#
# Copyright 2007 Christian Faulhammer <opfer@gentoo.org>
# Copyright 2002-2007 Matthew Kennedy <mkennedy@gentoo.org>
@@ -102,22 +102,44 @@
# pkg_postinst() {
# elisp-site-regen
# }
+#
# pkg_postrm() {
# elisp-site-regen
# }
#
+# When having optional Emacs support, you should prepend "use emacs &&" to
+# above calls of elisp-site-regen(). Don't use "has_version virtual/emacs"!
+# When unmerging the state of the USE flag emacs is taken from the package
+# database and not from the environment, so it is no problem when you unset
+# USE=emacs between merge und unmerge of a package.
+#
+# Miscellaneous functions:
+# ------------------------
+#
+# elisp-emacs-version() outputs the version of the currently active Emacs.
+#
# As always: Feel free to contact Emacs team through emacs@gentoo.org if you
# have problems, suggestions or questions.
SITELISP=/usr/share/emacs/site-lisp
elisp-compile() {
- /usr/bin/emacs --batch -f batch-byte-compile --no-site-file --no-init-file $*
+ einfo "Compiling GNU Emacs Elisp files ..."
+ /usr/bin/emacs -batch -q --no-site-file -f batch-byte-compile $*
+}
+
+elisp-emacs-version() {
+ # Output version of currently active Emacs.
+ # The following will work for at least versions 18-22.
+ echo "(princ emacs-version)" >"${T}"/emacs-version.el
+ /usr/bin/emacs -batch -q --no-site-file -l "${T}"/emacs-version.el
}
elisp-make-autoload-file () {
local f="${1:-${PN}-autoloads.el}"
shift
+ einfo "Generating autoload file for GNU Emacs ..."
+
sed 's/^FF/\f/' >"${f}" <<-EOF
;;; ${f##*/} --- autoloads for ${P}
@@ -134,7 +156,8 @@ elisp-make-autoload-file () {
;; End:
;;; ${f##*/} ends here
EOF
- emacs --batch -q --no-site-file \
+
+ /usr/bin/emacs -batch -q --no-site-file \
--eval "(setq make-backup-files nil)" \
--eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \
-f batch-update-autoloads "${@-.}"
@@ -142,6 +165,7 @@ elisp-make-autoload-file () {
elisp-install() {
local subdir=$1
+ einfo "Installing Elisp files for GNU Emacs support ..."
dodir "${SITELISP}/${subdir}"
insinto "${SITELISP}/${subdir}"
shift
@@ -150,6 +174,7 @@ elisp-install() {
elisp-site-file-install() {
local sitefile=$1 my_pn=${2:-${PN}}
+ einfo "Installing site initialisation file for GNU Emacs ..."
pushd "${S}"
cp ${sitefile} "${T}"
sed -i "s:@SITELISP@:${SITELISP}/${my_pn}:g" "${T}/$(basename ${sitefile})"
@@ -159,20 +184,33 @@ elisp-site-file-install() {
}
elisp-site-regen() {
+ local sflist sf line
+
einfo "Regenerating ${SITELISP}/site-gentoo.el ..."
- einfo ""
- cat <<EOF >${ROOT}${SITELISP}/site-gentoo.el
+ cat <<EOF >"${T}"/site-gentoo.el
;;; DO NOT EDIT THIS FILE -- IT IS GENERATED AUTOMATICALLY BY PORTAGE
;;; -----------------------------------------------------------------
EOF
- for sf in ${ROOT}${SITELISP}/[0-9][0-9]*-gentoo.el
+ for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el
do
[ -r "${sf}" ] || continue
- einfo " Adding $(basename ${sf}) ..."
- cat "${sf}" >>${ROOT}${SITELISP}/site-gentoo.el
+ sflist="${sflist} $(basename "${sf}")"
+ cat "${sf}" >>"${T}"/site-gentoo.el
done
- while read line; do einfo "${line}"; done <<EOF
+
+ if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then
+ # This prevents outputting unnecessary text when there
+ # was actually no change
+ # A case is a remerge where we have doubled output
+ einfo "... no changes"
+ else
+ mv -b "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el
+ einfo ""
+ for sf in ${sflist}; do
+ einfo " Adding ${sf} ..."
+ done
+ while read line; do einfo "${line}"; done <<EOF
All site initialization for Gentoo-installed packages is now added to
/usr/share/emacs/site-lisp/site-gentoo.el; site-start.el is no longer
@@ -189,43 +227,46 @@ can be added by individual users to their initialization files, or for
greater flexibility, users can select which of the package-specific
initialization files in /usr/share/emacs/site-lisp to load.
EOF
- echo
+ echo
+ fi
}
# The following Emacs Lisp compilation routine is taken from GNU
# autotools.
elisp-comp() {
-# Copyright 1995 Free Software Foundation, Inc.
-# François Pinard <pinard@iro.umontreal.ca>, 1995.
-# This script byte-compiles all `.el' files which are part of its
-# arguments, using GNU Emacs, and put the resulting `.elc' files into
-# the current directory, so disregarding the original directories used
-# in `.el' arguments.
-#
-# This script manages in such a way that all Emacs LISP files to
-# be compiled are made visible between themselves, in the event
-# they require or load-library one another.
-
- if test $# = 0; then
- exit 1
- else
- if test -z "${EMACS}" || test "${EMACS}" = "t"; then
+ # Copyright 1995 Free Software Foundation, Inc.
+ # François Pinard <pinard@iro.umontreal.ca>, 1995.
+ # This script byte-compiles all `.el' files which are part of its
+ # arguments, using GNU Emacs, and put the resulting `.elc' files into
+ # the current directory, so disregarding the original directories used
+ # in `.el' arguments.
+ #
+ # This script manages in such a way that all Emacs LISP files to
+ # be compiled are made visible between themselves, in the event
+ # they require or load-library one another.
+
+ test $# -gt 0 || return 1
+
+ if test -z "${EMACS}" || test "${EMACS}" = "t"; then
# Value of "t" means we are running in a shell under Emacs.
# Just assume Emacs is called "emacs".
- EMACS=emacs
- fi
+ EMACS=/usr/bin/emacs
+ fi
+ einfo "Compiling GNU Emacs Elisp files ..."
- tempdir=elc.$$
- mkdir ${tempdir}
- cp $* ${tempdir}
- cd ${tempdir}
+ tempdir=elc.$$
+ mkdir ${tempdir}
+ cp $* ${tempdir}
+ pushd ${tempdir}
- echo "(add-to-list 'load-path \"../\")" > script
- ${EMACS} -batch -q --no-site-file --no-init-file -l script -f batch-byte-compile *.el
- mv *.elc ..
+ echo "(add-to-list 'load-path \"../\")" > script
+ ${EMACS} -batch -q --no-site-file --no-init-file -l script \
+ -f batch-byte-compile *.el
+ local status=$?
+ mv *.elc ..
- cd ..
- rm -fr ${tempdir}
- fi
+ popd
+ rm -fr ${tempdir}
+ return ${status}
}
diff --git a/eclass/elisp.eclass b/eclass/elisp.eclass
index 5108685537c4..c8df6b129806 100644
--- a/eclass/elisp.eclass
+++ b/eclass/elisp.eclass
@@ -1,10 +1,11 @@
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/elisp.eclass,v 1.18 2007/04/16 15:41:02 opfer Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/elisp.eclass,v 1.19 2007/07/02 06:19:18 opfer Exp $
#
# Copyright 2007 Christian Faulhammer <opfer@gentoo.org>
# Copyright 2002-2007 Matthew Kennedy <mkennedy@gentoo.org>
# Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com>
+# Copyright 2007 Ulrich Mueller <ulm@gentoo.org>
#
# This eclass sets the site-lisp directory for emacs-related packages.
#
@@ -13,41 +14,59 @@
# itself. All elisp-* functions are documented there.
#
# Setting SIMPLE_ELISP=t in an ebuild means, that the package's source
-# is a single (in whatever way) compressed elisp file with the file name
-# ${PN}-${PV}. The consequences:
+# is a single (in whatever way) compressed elisp file with the file name
+# ${PN}-${PV}. The consequences:
#
# 1.) ${S} is redefined
# 2.) ${PN}-${PV}.el is moved to ${PN} in the system.
#
-
-inherit elisp-common
-
# SRC_URI should be set to wherever the primary app-emacs/ maintainer
# keeps the local elisp mirror, since most app-emacs packages are
# upstream as a single .el file.
+#
+# DOCS="blah.txt ChangeLog" is automatically used to install the given
+# files by dodoc in src_install().
+#
+# If you need anything different from Emacs 21, use the NEED_EMACS
+# variable before inheriting elisp.eclass. Set it to the major version
+# your package uses and the dependency will be adjusted.
+
+inherit elisp-common versionator
+
+VERSION=${NEED_EMACS:-21}
+DEPEND=">=virtual/emacs-${VERSION}"
+IUSE=""
if [ "${SIMPLE_ELISP}" = 't' ]; then
S="${WORKDIR}/"
fi
-DEPEND="virtual/emacs"
-IUSE=""
+elisp_pkg_setup() {
+ local emacs_version="$(elisp-emacs-version)"
+ if ! version_is_at_least "${VERSION}" "${emacs_version}"; then
+ eerror "This package needs at least Emacs ${VERSION}."
+ eerror "Use \"eselect emacs\" to select the active version."
+ die "Emacs version ${emacs_version} is too low."
+ fi
+}
elisp_src_unpack() {
unpack ${A}
- if [ "${SIMPLE_ELISP}" = 't' ]
- then
+ if [ "${SIMPLE_ELISP}" = 't' ]; then
cd "${S}" && mv ${P}.el ${PN}.el
fi
}
elisp_src_compile() {
- elisp-compile *.el || die
+ elisp-compile *.el || die "elisp-compile failed"
}
elisp_src_install() {
elisp-install ${PN} *.el *.elc
elisp-site-file-install "${FILESDIR}/${SITEFILE}"
+ if [ -n "${DOCS}" ]; then
+ dodoc ${DOCS} || die "dodoc failed"
+ fi
}
elisp_pkg_postinst() {
@@ -58,4 +77,5 @@ elisp_pkg_postrm() {
elisp-site-regen
}
-EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
+EXPORT_FUNCTIONS src_unpack src_compile src_install
+EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_postrm