diff options
author | Hans de Graaff <graaff@gentoo.org> | 2011-06-26 19:06:59 +0000 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2011-06-26 19:06:59 +0000 |
commit | 94c85d2387742223a7d0998a83707063f9769d0e (patch) | |
tree | 399b294fd0f35a2fa493f6bf7ec6e36eeb7624de /eclass/xemacs-elisp-common.eclass | |
parent | Added live ebuild. (diff) | |
download | historical-94c85d2387742223a7d0998a83707063f9769d0e.tar.gz historical-94c85d2387742223a7d0998a83707063f9769d0e.tar.bz2 historical-94c85d2387742223a7d0998a83707063f9769d0e.zip |
Sync sitefile support from elisp-common.eclass. XEmacs can now use the same mechanism to install sitefile code, sans the backwards compatible provisions.
Diffstat (limited to 'eclass/xemacs-elisp-common.eclass')
-rw-r--r-- | eclass/xemacs-elisp-common.eclass | 169 |
1 files changed, 167 insertions, 2 deletions
diff --git a/eclass/xemacs-elisp-common.eclass b/eclass/xemacs-elisp-common.eclass index fc572f7691f9..2897e5ec6fe5 100644 --- a/eclass/xemacs-elisp-common.eclass +++ b/eclass/xemacs-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/xemacs-elisp-common.eclass,v 1.3 2009/06/21 14:53:12 graaff Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.4 2011/06/26 19:06:59 graaff Exp $ # # Copyright 2007 Hans de Graaff <graaff@gentoo.org> # @@ -63,10 +63,70 @@ # # xemacs-elisp-install ${PN} *.el *.elc # +# To let the XEmacs support be activated by XEmacs on startup, you need +# to provide a site file (shipped in ${FILESDIR}) which contains the +# startup code (have a look in the documentation of your software). +# Normally this would look like this: +# +# (add-to-list 'load-path "@SITELISP@") +# (add-to-list 'auto-mode-alist '("\\.csv\\'" . csv-mode)) +# (autoload 'csv-mode "csv-mode" "Major mode for csv files." t) +# +# If your XEmacs support files are installed in a subdirectory of +# /usr/share/xemacs/site-packages/ (which is strongly recommended), you need +# to extend XEmacs' load-path as shown in the first non-comment line. +# The xemacs-elisp-site-file-install() function of this eclass will replace +# "@SITELISP@" by the actual path. +# +# The next line tells XEmacs to load the mode opening a file ending +# with ".csv" and load functions depending on the context and needed +# features. Be careful though. Commands as "load-library" or "require" +# bloat the editor as they are loaded on every startup. When having +# many XEmacs support files, users may be annoyed by the start-up time. +# Also avoid keybindings as they might interfere with the user's +# settings. Give a hint in pkg_postinst(), which should be enough. +# +# The naming scheme for this site-init file matches the shell pattern +# "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define +# the loading order (numbers below 10 or above 89 are reserved for +# internal use). So if your initialisation depends on another XEmacs +# package, your site file's number must be higher! If there are no such +# interdependencies then the number should be 50. Otherwise, numbers +# divisible by 10 are preferred. +# +# Best practice is to define a SITEFILE variable in the global scope of +# your ebuild (e.g., right after S or RDEPEND): +# +# SITEFILE="50${PN}-gentoo.el" +# +# Which is then installed by +# +# xemacs-elisp-site-file-install "${FILESDIR}/${SITEFILE}" || die +# +# in src_install(). Any characters after the "-gentoo" part and before +# the extension will be stripped from the destination file's name. +# For example, a file "50${PN}-gentoo-${PV}.el" will be installed as +# "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give +# the differing name as second argument. +# @ECLASS-VARIABLE: SITELISP +# @DESCRIPTION: +# Directory where packages install indivivual XEmacs Lisp files. +SITELISP=/usr/share/xemacs/site-lisp + +# @ECLASS-VARIABLE: SITEPACKAGE +# @DESCRIPTION: +# Directory where packages install XEmacs Lisp packages. +SITEPACKAGE=/usr/share/xemacs/site-packages -SITEPACKAGE=/usr/lib/xemacs/site-packages +# @ECLASS-VARIABLE: XEMACS +# @DESCRIPTION: +# Path of XEmacs executable. XEMACS=/usr/bin/xemacs + +# @ECLASS-VARIABLE: XEMACS_BATCH_CLEAN +# @DESCRIPTION: +# Invocation of XEMACS in batch mode. XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" # @FUNCTION: xemacs-elisp-compile @@ -144,3 +204,108 @@ xemacs-elisp-comp() { rm -fr ${tempdir} return ${ret} } + +# @FUNCTION: xemacs-elisp-site-file-install +# @USAGE: <site-init file> [subdirectory] +# @DESCRIPTION: +# Install XEmacs site-init file in SITELISP directory. Automatically +# inserts a standard comment header with the name of the package (unless +# it is already present). Tokens @SITELISP@ is replaced by the path to +# the package's subdirectory in SITELISP. + +xemacs-elisp-site-file-install() { + local sf="${1##*/}" my_pn="${2:-${PN}}" ret + local header=";;; ${PN} site-lisp configuration" + + [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ + || ewarn "xemacs-elisp-site-file-install: bad name of site-init file" + sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" + ebegin "Installing site initialisation file for XEmacs" + [[ $1 = "${sf}" ]] || cp "$1" "${sf}" + sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ + -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" "${sf}" + ( # subshell to avoid pollution of calling environment + insinto "${SITELISP}/site-gentoo.d" + doins "${sf}" + ) + ret=$? + rm -f "${sf}" + eend ${ret} "xemacs-elisp-site-file-install: doins failed" +} + +# @FUNCTION: xemacs-elisp-site-regen +# @DESCRIPTION: +# Regenerate the site-gentoo.el file, based on packages' site +# initialisation files in the /usr/share/xemacs/site-lisp/site-gentoo.d/ +# directory. + +xemacs-elisp-site-regen() { + local sitelisp=${ROOT}${EPREFIX}${SITELISP} + local sf i line null="" page=$'\f' + local -a sflist + + if [ ! -d "${sitelisp}" ]; then + eerror "xemacs-elisp-site-regen: Directory ${sitelisp} does not exist" + return 1 + fi + + if [ ! -d "${T}" ]; then + eerror "xemacs-elisp-site-regen: Temporary directory ${T} does not exist" + return 1 + fi + + einfon "Regenerating site-gentoo.el for XEmacs (${EBUILD_PHASE}) ..." + + for sf in "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el + do + [ -r "${sf}" ] || continue + # sort files by their basename. straight insertion sort. + for ((i=${#sflist[@]}; i>0; i--)); do + [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break + sflist[i]=${sflist[i-1]} + done + sflist[i]=${sf} + done + + cat <<-EOF >"${T}"/site-gentoo.el + ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages + + ;;; Commentary: + ;; Automatically generated by xemacs-elisp-common.eclass + ;; DO NOT EDIT THIS FILE + + ;;; Code: + EOF + # Use sed instead of cat here, since files may miss a trailing newline. + sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el + cat <<-EOF >>"${T}"/site-gentoo.el + + ${page} + (provide 'site-gentoo) + + ;; Local ${null}Variables: + ;; no-byte-compile: t + ;; buffer-read-only: t + ;; End: + + ;;; site-gentoo.el ends here + EOF + + if cmp -s "${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. + rm -f "${T}"/site-gentoo.el + echo " no changes." + else + mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el + echo + case ${#sflist[@]} in + 0) ewarn "... Huh? No site initialisation files found." ;; + 1) einfo "... ${#sflist[@]} site initialisation file included." ;; + *) einfo "... ${#sflist[@]} site initialisation files included." ;; + esac + fi + + return 0 +} |