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

Diff of /eclass/elisp-common.eclass

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

Revision 1.31 Revision 1.32
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/elisp-common.eclass,v 1.31 2007/12/01 15:35:02 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.32 2007/12/11 12:28:05 ulm Exp $
4# 4#
5# Copyright 2007 Christian Faulhammer <opfer@gentoo.org> 5# Copyright 2007 Christian Faulhammer <opfer@gentoo.org>
6# Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> 6# Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org>
7# Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> 7# Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org>
8# Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> 8# Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com>
148# @USAGE: <list of elisp files> 148# @USAGE: <list of elisp files>
149# @DESCRIPTION: 149# @DESCRIPTION:
150# Byte-compile Emacs Lisp files. 150# Byte-compile Emacs Lisp files.
151 151
152elisp-compile() { 152elisp-compile() {
153 einfo "Compiling GNU Emacs Elisp files ..." 153 ebegin "Compiling GNU Emacs Elisp files"
154 ${EMACS} ${EMACSFLAGS} -f batch-byte-compile "$@" 154 ${EMACS} ${EMACSFLAGS} -f batch-byte-compile "$@"
155 eend $? "batch-byte-compile failed"
155} 156}
156 157
157# @FUNCTION: elisp-comp 158# @FUNCTION: elisp-comp
158# @USAGE: <list of elisp files> 159# @USAGE: <list of elisp files>
159# @DESCRIPTION: 160# @DESCRIPTION:
173 # Fran├žois Pinard <pinard@iro.umontreal.ca>, 1995. 174 # Fran├žois Pinard <pinard@iro.umontreal.ca>, 1995.
174 # Originally taken from GNU autotools. 175 # Originally taken from GNU autotools.
175 176
176 [ $# -gt 0 ] || return 1 177 [ $# -gt 0 ] || return 1
177 178
178 einfo "Compiling GNU Emacs Elisp files ..." 179 ebegin "Compiling GNU Emacs Elisp files"
179 180
180 tempdir=elc.$$ 181 tempdir=elc.$$
181 mkdir ${tempdir} 182 mkdir ${tempdir}
182 cp "$@" ${tempdir} 183 cp "$@" ${tempdir}
183 pushd ${tempdir} 184 pushd ${tempdir}
187 local ret=$? 188 local ret=$?
188 mv *.elc .. 189 mv *.elc ..
189 190
190 popd 191 popd
191 rm -fr ${tempdir} 192 rm -fr ${tempdir}
193
194 eend ${ret} "batch-byte-compile failed"
192 return ${ret} 195 return ${ret}
193} 196}
194 197
195# @FUNCTION: elisp-emacs-version 198# @FUNCTION: elisp-emacs-version
196# @DESCRIPTION: 199# @DESCRIPTION:
208# Generate a file with autoload definitions for the lisp functions. 211# Generate a file with autoload definitions for the lisp functions.
209 212
210elisp-make-autoload-file() { 213elisp-make-autoload-file() {
211 local f="${1:-${PN}-autoloads.el}" 214 local f="${1:-${PN}-autoloads.el}"
212 shift 215 shift
213 einfo "Generating autoload file for GNU Emacs ..." 216 ebegin "Generating autoload file for GNU Emacs"
214 217
215 sed 's/^FF/\f/' >"${f}" <<-EOF 218 sed 's/^FF/\f/' >"${f}" <<-EOF
216 ;;; ${f##*/} --- autoloads for ${P} 219 ;;; ${f##*/} --- autoloads for ${P}
217 220
218 ;;; Commentary: 221 ;;; Commentary:
231 234
232 ${EMACS} ${EMACSFLAGS} \ 235 ${EMACS} ${EMACSFLAGS} \
233 --eval "(setq make-backup-files nil)" \ 236 --eval "(setq make-backup-files nil)" \
234 --eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \ 237 --eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \
235 -f batch-update-autoloads "${@-.}" 238 -f batch-update-autoloads "${@-.}"
239
240 eend $? "batch-update-autoloads failed"
236} 241}
237 242
238# @FUNCTION: elisp-install 243# @FUNCTION: elisp-install
239# @USAGE: <subdirectory> <list of files> 244# @USAGE: <subdirectory> <list of files>
240# @DESCRIPTION: 245# @DESCRIPTION:
241# Install files in SITELISP directory. 246# Install files in SITELISP directory.
242 247
243elisp-install() { 248elisp-install() {
244 local subdir="$1" 249 local subdir="$1"
245 shift 250 shift
246 einfo "Installing Elisp files for GNU Emacs support ..." 251 ebegin "Installing Elisp files for GNU Emacs support"
247 ( # subshell to avoid pollution of calling environment 252 ( # subshell to avoid pollution of calling environment
248 insinto "${SITELISP}/${subdir}" 253 insinto "${SITELISP}/${subdir}"
249 doins "$@" 254 doins "$@"
250 ) 255 )
256 eend $? "doins failed"
251} 257}
252 258
253# @FUNCTION: elisp-site-file-install 259# @FUNCTION: elisp-site-file-install
254# @USAGE: <site-init file> [subdirectory] 260# @USAGE: <site-init file> [subdirectory]
255# @DESCRIPTION: 261# @DESCRIPTION:
256# Install Emacs site-init file in SITELISP directory. 262# Install Emacs site-init file in SITELISP directory.
257 263
258elisp-site-file-install() { 264elisp-site-file-install() {
259 local sf="$1" my_pn="${2:-${PN}}" 265 local sf="$1" my_pn="${2:-${PN}}"
260 einfo "Installing site initialisation file for GNU Emacs ..." 266 ebegin "Installing site initialisation file for GNU Emacs"
261 cp "${sf}" "${T}" 267 cp "${sf}" "${T}"
262 sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ 268 sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \
263 -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf##*/}" 269 -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf##*/}"
264 ( # subshell to avoid pollution of calling environment 270 ( # subshell to avoid pollution of calling environment
265 insinto "${SITELISP}" 271 insinto "${SITELISP}"
266 doins "${T}/${sf##*/}" 272 doins "${T}/${sf##*/}"
267 ) 273 )
274 eend $? "doins failed"
268} 275}
269 276
270# @FUNCTION: elisp-site-regen 277# @FUNCTION: elisp-site-regen
271# @DESCRIPTION: 278# @DESCRIPTION:
272# Regenerate site-gentoo.el file. 279# Regenerate site-gentoo.el file.
273 280
281# Old location for site initialisation files of packages was
282# /usr/share/emacs/site-lisp/. It is planned to change this to
283# /usr/share/emacs/site-lisp/site-gentoo.d/.
284
274elisp-site-regen() { 285elisp-site-regen() {
275 local sflist sf line 286 local i sf line
287 local -a sflist
276 288
277 if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \ 289 if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \
278 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then 290 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then
279 einfo "Creating default ${SITELISP}/site-start.el ..." 291 einfo "Creating default ${SITELISP}/site-start.el ..."
280 cat <<-EOF >"${T}"/site-start.el 292 cat <<-EOF >"${T}"/site-start.el
292 ;;; site-start.el ends here 304 ;;; site-start.el ends here
293 EOF 305 EOF
294 fi 306 fi
295 307
296 einfon "Regenerating ${SITELISP}/site-gentoo.el ..." 308 einfon "Regenerating ${SITELISP}/site-gentoo.el ..."
309
310 # remove auxiliary file
311 rm -f "${ROOT}${SITELISP}"/00site-gentoo.el
312
313 # set nullglob option, there may be a directory without matching files
314 local old_shopts=$(shopt -p nullglob)
315 shopt -s nullglob
316
317 for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el \
318 "${ROOT}${SITELISP}"/site-gentoo.d/[0-9][0-9]*.el
319 do
320 [ -r "${sf}" ] || continue
321 # sort files by their basename. straight insertion sort.
322 for ((i=${#sflist[@]}; i>0; i--)); do
323 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
324 sflist[i]=${sflist[i-1]}
325 done
326 sflist[i]=${sf}
327 done
328
329 eval "${old_shopts}"
330
297 cat <<-EOF >"${T}"/site-gentoo.el 331 cat <<-EOF >"${T}"/site-gentoo.el
298 ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages 332 ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
299 333
300 ;;; Commentary: 334 ;;; Commentary:
301 ;; Automatically generated by elisp-common.eclass 335 ;; Automatically generated by elisp-common.eclass
302 ;; DO NOT EDIT THIS FILE 336 ;; DO NOT EDIT THIS FILE
303 337
304 ;;; Code: 338 ;;; Code:
305 EOF 339 EOF
306
307 for sf in "${ROOT}${SITELISP}"/[0-9][0-9]*-gentoo.el
308 do
309 [ -r "${sf}" ] || continue
310 sflist="${sflist} ${sf##*/}"
311 cat "${sf}" >>"${T}"/site-gentoo.el 340 cat "${sflist[@]}" >>"${T}"/site-gentoo.el
312 done
313
314 cat <<-EOF >>"${T}"/site-gentoo.el 341 cat <<-EOF >>"${T}"/site-gentoo.el
315 342
316 (provide 'site-gentoo) 343 (provide 'site-gentoo)
317 344
318 ;; Local Variables: 345 ;; Local Variables:
330 mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el 357 mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el
331 [ -f "${T}"/site-start.el ] \ 358 [ -f "${T}"/site-start.el ] \
332 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ 359 && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \
333 && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el 360 && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el
334 echo; einfo 361 echo; einfo
335 for sf in ${sflist}; do 362 for sf in "${sflist[@]##*/}"; do
336 einfo " Adding ${sf} ..." 363 einfo " Adding ${sf} ..."
337 done 364 done
365 einfo "Regenerated ${SITELISP}/site-gentoo.el."
366
367 echo
338 while read line; do einfo "${line}"; done <<EOF 368 while read line; do einfo "${line}"; done <<EOF
339
340All site initialisation for Gentoo-installed packages is added to 369All site initialisation for Gentoo-installed packages is added to
341/usr/share/emacs/site-lisp/site-gentoo.el; site-start.el is no longer 370/usr/share/emacs/site-lisp/site-gentoo.el; site-start.el is no longer
342managed by Gentoo. You are responsible for all maintenance of 371managed by Gentoo. You are responsible for all maintenance of
343site-start.el if there is such a file. 372site-start.el if there is such a file.
344 373
352for greater flexibility, users can load individual package-specific 381for greater flexibility, users can load individual package-specific
353initialisation files from /usr/share/emacs/site-lisp/. 382initialisation files from /usr/share/emacs/site-lisp/.
354EOF 383EOF
355 echo 384 echo
356 fi 385 fi
386
387 # Kludge for backwards compatibility: During pkg_postrm, old versions
388 # of this eclass (saved in the PDB) won't find packages' site-init files
389 # in the new location. So we copy them to an auxiliary file that is
390 # visible to old eclass versions.
391 for sf in "${sflist[@]}"; do
392 [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \
393 && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el
394 done
357} 395}

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.20