/[gentoo-x86]/eclass/xemacs-elisp-common.eclass
Gentoo

Diff of /eclass/xemacs-elisp-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.4
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.3 2009/06/21 14:53:12 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.4 2011/06/26 19:06:59 graaff Exp $
4# 4#
5# Copyright 2007 Hans de Graaff <graaff@gentoo.org> 5# Copyright 2007 Hans de Graaff <graaff@gentoo.org>
6# 6#
7# Based on elisp-common.eclass: 7# Based on elisp-common.eclass:
8# Copyright 2007 Christian Faulhammer <opfer@gentoo.org> 8# Copyright 2007 Christian Faulhammer <opfer@gentoo.org>
61# the files to be put in that directory. Usually the subdirectory 61# the files to be put in that directory. Usually the subdirectory
62# should be ${PN}, but you can choose something else. 62# should be ${PN}, but you can choose something else.
63# 63#
64# xemacs-elisp-install ${PN} *.el *.elc 64# xemacs-elisp-install ${PN} *.el *.elc
65# 65#
66# To let the XEmacs support be activated by XEmacs on startup, you need
67# to provide a site file (shipped in ${FILESDIR}) which contains the
68# startup code (have a look in the documentation of your software).
69# Normally this would look like this:
70#
71# (add-to-list 'load-path "@SITELISP@")
72# (add-to-list 'auto-mode-alist '("\\.csv\\'" . csv-mode))
73# (autoload 'csv-mode "csv-mode" "Major mode for csv files." t)
74#
75# If your XEmacs support files are installed in a subdirectory of
76# /usr/share/xemacs/site-packages/ (which is strongly recommended), you need
77# to extend XEmacs' load-path as shown in the first non-comment line.
78# The xemacs-elisp-site-file-install() function of this eclass will replace
79# "@SITELISP@" by the actual path.
80#
81# The next line tells XEmacs to load the mode opening a file ending
82# with ".csv" and load functions depending on the context and needed
83# features. Be careful though. Commands as "load-library" or "require"
84# bloat the editor as they are loaded on every startup. When having
85# many XEmacs support files, users may be annoyed by the start-up time.
86# Also avoid keybindings as they might interfere with the user's
87# settings. Give a hint in pkg_postinst(), which should be enough.
88#
89# The naming scheme for this site-init file matches the shell pattern
90# "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define
91# the loading order (numbers below 10 or above 89 are reserved for
92# internal use). So if your initialisation depends on another XEmacs
93# package, your site file's number must be higher! If there are no such
94# interdependencies then the number should be 50. Otherwise, numbers
95# divisible by 10 are preferred.
96#
97# Best practice is to define a SITEFILE variable in the global scope of
98# your ebuild (e.g., right after S or RDEPEND):
99#
100# SITEFILE="50${PN}-gentoo.el"
101#
102# Which is then installed by
103#
104# xemacs-elisp-site-file-install "${FILESDIR}/${SITEFILE}" || die
105#
106# in src_install(). Any characters after the "-gentoo" part and before
107# the extension will be stripped from the destination file's name.
108# For example, a file "50${PN}-gentoo-${PV}.el" will be installed as
109# "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give
110# the differing name as second argument.
66 111
112# @ECLASS-VARIABLE: SITELISP
113# @DESCRIPTION:
114# Directory where packages install indivivual XEmacs Lisp files.
115SITELISP=/usr/share/xemacs/site-lisp
67 116
117# @ECLASS-VARIABLE: SITEPACKAGE
118# @DESCRIPTION:
119# Directory where packages install XEmacs Lisp packages.
68SITEPACKAGE=/usr/lib/xemacs/site-packages 120SITEPACKAGE=/usr/share/xemacs/site-packages
121
122# @ECLASS-VARIABLE: XEMACS
123# @DESCRIPTION:
124# Path of XEmacs executable.
69XEMACS=/usr/bin/xemacs 125XEMACS=/usr/bin/xemacs
126
127# @ECLASS-VARIABLE: XEMACS_BATCH_CLEAN
128# @DESCRIPTION:
129# Invocation of XEMACS in batch mode.
70XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" 130XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file"
71 131
72# @FUNCTION: xemacs-elisp-compile 132# @FUNCTION: xemacs-elisp-compile
73# @USAGE: <list of elisp files> 133# @USAGE: <list of elisp files>
74# @DESCRIPTION: 134# @DESCRIPTION:
142 202
143 popd 203 popd
144 rm -fr ${tempdir} 204 rm -fr ${tempdir}
145 return ${ret} 205 return ${ret}
146} 206}
207
208# @FUNCTION: xemacs-elisp-site-file-install
209# @USAGE: <site-init file> [subdirectory]
210# @DESCRIPTION:
211# Install XEmacs site-init file in SITELISP directory. Automatically
212# inserts a standard comment header with the name of the package (unless
213# it is already present). Tokens @SITELISP@ is replaced by the path to
214# the package's subdirectory in SITELISP.
215
216xemacs-elisp-site-file-install() {
217 local sf="${1##*/}" my_pn="${2:-${PN}}" ret
218 local header=";;; ${PN} site-lisp configuration"
219
220 [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
221 || ewarn "xemacs-elisp-site-file-install: bad name of site-init file"
222 sf="${T}/${sf/%-gentoo*.el/-gentoo.el}"
223 ebegin "Installing site initialisation file for XEmacs"
224 [[ $1 = "${sf}" ]] || cp "$1" "${sf}"
225 sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \
226 -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" "${sf}"
227 ( # subshell to avoid pollution of calling environment
228 insinto "${SITELISP}/site-gentoo.d"
229 doins "${sf}"
230 )
231 ret=$?
232 rm -f "${sf}"
233 eend ${ret} "xemacs-elisp-site-file-install: doins failed"
234}
235
236# @FUNCTION: xemacs-elisp-site-regen
237# @DESCRIPTION:
238# Regenerate the site-gentoo.el file, based on packages' site
239# initialisation files in the /usr/share/xemacs/site-lisp/site-gentoo.d/
240# directory.
241
242xemacs-elisp-site-regen() {
243 local sitelisp=${ROOT}${EPREFIX}${SITELISP}
244 local sf i line null="" page=$'\f'
245 local -a sflist
246
247 if [ ! -d "${sitelisp}" ]; then
248 eerror "xemacs-elisp-site-regen: Directory ${sitelisp} does not exist"
249 return 1
250 fi
251
252 if [ ! -d "${T}" ]; then
253 eerror "xemacs-elisp-site-regen: Temporary directory ${T} does not exist"
254 return 1
255 fi
256
257 einfon "Regenerating site-gentoo.el for XEmacs (${EBUILD_PHASE}) ..."
258
259 for sf in "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el
260 do
261 [ -r "${sf}" ] || continue
262 # sort files by their basename. straight insertion sort.
263 for ((i=${#sflist[@]}; i>0; i--)); do
264 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
265 sflist[i]=${sflist[i-1]}
266 done
267 sflist[i]=${sf}
268 done
269
270 cat <<-EOF >"${T}"/site-gentoo.el
271 ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
272
273 ;;; Commentary:
274 ;; Automatically generated by xemacs-elisp-common.eclass
275 ;; DO NOT EDIT THIS FILE
276
277 ;;; Code:
278 EOF
279 # Use sed instead of cat here, since files may miss a trailing newline.
280 sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el
281 cat <<-EOF >>"${T}"/site-gentoo.el
282
283 ${page}
284 (provide 'site-gentoo)
285
286 ;; Local ${null}Variables:
287 ;; no-byte-compile: t
288 ;; buffer-read-only: t
289 ;; End:
290
291 ;;; site-gentoo.el ends here
292 EOF
293
294 if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then
295 # This prevents outputting unnecessary text when there
296 # was actually no change.
297 # A case is a remerge where we have doubled output.
298 rm -f "${T}"/site-gentoo.el
299 echo " no changes."
300 else
301 mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el
302 echo
303 case ${#sflist[@]} in
304 0) ewarn "... Huh? No site initialisation files found." ;;
305 1) einfo "... ${#sflist[@]} site initialisation file included." ;;
306 *) einfo "... ${#sflist[@]} site initialisation files included." ;;
307 esac
308 fi
309
310 return 0
311}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20