diff options
author | Christian Faulhammer <opfer@gentoo.org> | 2007-07-02 06:19:18 +0000 |
---|---|---|
committer | Christian Faulhammer <opfer@gentoo.org> | 2007-07-02 06:19:18 +0000 |
commit | cda0c87189ee9926868046855f899e539155ec27 (patch) | |
tree | 51d70a7ec52c79bf3bb8ccea660f03ff8fb3dd4d /eclass/elisp-common.eclass | |
parent | Adding Changelog which I missed. (diff) | |
download | gentoo-2-cda0c87189ee9926868046855f899e539155ec27.tar.gz gentoo-2-cda0c87189ee9926868046855f899e539155ec27.tar.bz2 gentoo-2-cda0c87189ee9926868046855f899e539155ec27.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/elisp-common.eclass')
-rw-r--r-- | eclass/elisp-common.eclass | 115 |
1 files changed, 78 insertions, 37 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} } |