/[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.27 Revision 1.28
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.27 2007/08/27 19:41:03 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.28 2007/09/22 20:25:30 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>
127# 127#
128# elisp-emacs-version() outputs the version of the currently active Emacs. 128# elisp-emacs-version() outputs the version of the currently active Emacs.
129 129
130SITELISP=/usr/share/emacs/site-lisp 130SITELISP=/usr/share/emacs/site-lisp
131SITEFILE=50${PN}-gentoo.el 131SITEFILE=50${PN}-gentoo.el
132EMACS=/usr/bin/emacs
133# The following works for Emacs versions 18-23, don't change it.
134EMACS_BATCH_CLEAN="${EMACS} -batch -q --no-site-file"
132 135
133# @FUNCTION: elisp-compile 136# @FUNCTION: elisp-compile
134# @USAGE: <list of elisp files> 137# @USAGE: <list of elisp files>
135# @DESCRIPTION: 138# @DESCRIPTION:
136# Byte-compile Emacs Lisp files. 139# Byte-compile Emacs Lisp files.
137 140
138elisp-compile() { 141elisp-compile() {
139 einfo "Compiling GNU Emacs Elisp files ..." 142 einfo "Compiling GNU Emacs Elisp files ..."
140 /usr/bin/emacs -batch -q --no-site-file -f batch-byte-compile $* 143 ${EMACS_BATCH_CLEAN} -f batch-byte-compile "$@"
141} 144}
142 145
143# @FUNCTION: elisp-emacs-version 146# @FUNCTION: elisp-emacs-version
144# @DESCRIPTION: 147# @DESCRIPTION:
145# Output version of currently active Emacs. 148# Output version of currently active Emacs.
146 149
147elisp-emacs-version() { 150elisp-emacs-version() {
148 # The following will work for at least versions 18-22. 151 # The following will work for at least versions 18-23.
149 echo "(princ emacs-version)" >"${T}"/emacs-version.el 152 echo "(princ emacs-version)" >"${T}"/emacs-version.el
150 /usr/bin/emacs -batch -q --no-site-file -l "${T}"/emacs-version.el 153 ${EMACS_BATCH_CLEAN} -l "${T}"/emacs-version.el
151} 154}
152 155
153# @FUNCTION: elisp-make-autoload-file 156# @FUNCTION: elisp-make-autoload-file
154# @USAGE: [output file] [list of directories] 157# @USAGE: [output file] [list of directories]
155# @DESCRIPTION: 158# @DESCRIPTION:
175 ;; no-update-autoloads: t 178 ;; no-update-autoloads: t
176 ;; End: 179 ;; End:
177 ;;; ${f##*/} ends here 180 ;;; ${f##*/} ends here
178 EOF 181 EOF
179 182
180 /usr/bin/emacs -batch -q --no-site-file \ 183 ${EMACS_BATCH_CLEAN} \
181 --eval "(setq make-backup-files nil)" \ 184 --eval "(setq make-backup-files nil)" \
182 --eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \ 185 --eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \
183 -f batch-update-autoloads "${@-.}" 186 -f batch-update-autoloads "${@-.}"
184} 187}
185 188
187# @USAGE: <subdirectory> <list of files> 190# @USAGE: <subdirectory> <list of files>
188# @DESCRIPTION: 191# @DESCRIPTION:
189# Install files in SITELISP directory. 192# Install files in SITELISP directory.
190 193
191elisp-install() { 194elisp-install() {
192 local subdir=$1 195 local subdir="$1"
196 shift
193 einfo "Installing Elisp files for GNU Emacs support ..." 197 einfo "Installing Elisp files for GNU Emacs support ..."
194 dodir "${SITELISP}/${subdir}" 198 ( # subshell to avoid pollution of calling environment
195 insinto "${SITELISP}/${subdir}" 199 insinto "${SITELISP}/${subdir}"
196 shift
197 doins $@ 200 doins "$@"
201 )
198} 202}
199 203
200# @FUNCTION: elisp-site-file-install 204# @FUNCTION: elisp-site-file-install
201# @USAGE: <site-init file> [subdirectory] 205# @USAGE: <site-init file> [subdirectory]
202# @DESCRIPTION: 206# @DESCRIPTION:
203# Install Emacs site-init file in SITELISP directory. 207# Install Emacs site-init file in SITELISP directory.
204 208
205elisp-site-file-install() { 209elisp-site-file-install() {
206 local sitefile=$1 my_pn=${2:-${PN}} 210 local sf="$1" my_pn="${2:-${PN}}"
207 einfo "Installing site initialisation file for GNU Emacs ..." 211 einfo "Installing site initialisation file for GNU Emacs ..."
208 pushd "${S}"
209 cp ${sitefile} "${T}" 212 cp "${sf}" "${T}"
210 sed -i "s:@SITELISP@:${SITELISP}/${my_pn}:g" "${T}/$(basename ${sitefile})" 213 sed -i "s:@SITELISP@:${SITELISP}/${my_pn}:g" "${T}/$(basename "${sf}")"
214 ( # subshell to avoid pollution of calling environment
211 insinto ${SITELISP} 215 insinto "${SITELISP}"
212 doins "${T}/$(basename ${sitefile})" || die "failed to install site file" 216 doins "${T}/$(basename "${sf}")"
213 popd 217 )
214} 218}
215 219
216# @FUNCTION: elisp-site-regen 220# @FUNCTION: elisp-site-regen
217# @DESCRIPTION: 221# @DESCRIPTION:
218# Regenerate site-gentoo.el file. 222# Regenerate site-gentoo.el file.
238 cat "${sf}" >>"${T}"/site-gentoo.el 242 cat "${sf}" >>"${T}"/site-gentoo.el
239 done 243 done
240 244
241 cat <<-EOF >>"${T}"/site-gentoo.el 245 cat <<-EOF >>"${T}"/site-gentoo.el
242 246
247 (provide 'site-gentoo)
248
249 ;; Local Variables:
250 ;; no-byte-compile: t
251 ;; End:
243 ;;; site-gentoo.el ends here 252 ;;; site-gentoo.el ends here
244 EOF 253 EOF
245 254
246 if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then 255 if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then
247 # This prevents outputting unnecessary text when there 256 # This prevents outputting unnecessary text when there
277 286
278# @FUNCTION: elisp-comp 287# @FUNCTION: elisp-comp
279# @USAGE: <list of elisp files> 288# @USAGE: <list of elisp files>
280# @DESCRIPTION: 289# @DESCRIPTION:
281# Byte-compile interdependent Emacs Lisp files. 290# Byte-compile interdependent Emacs Lisp files.
282# Originally taken from GNU autotools. 291#
292# This function byte-compiles all ".el" files which are part of its
293# arguments, using GNU Emacs, and puts the resulting ".elc" files into the
294# current directory, so disregarding the original directories used in ".el"
295# arguments.
296#
297# This function manages in such a way that all Emacs Lisp files to be
298# compiled are made visible between themselves, in the event they require or
299# load one another.
283 300
284elisp-comp() { 301elisp-comp() {
285 # Copyright 1995 Free Software Foundation, Inc. 302 # Copyright 1995 Free Software Foundation, Inc.
286 # Fran├žois Pinard <pinard@iro.umontreal.ca>, 1995. 303 # Fran├žois Pinard <pinard@iro.umontreal.ca>, 1995.
287 # This script byte-compiles all `.el' files which are part of its 304 # Originally taken from GNU autotools.
288 # arguments, using GNU Emacs, and put the resulting `.elc' files into
289 # the current directory, so disregarding the original directories used
290 # in `.el' arguments.
291 #
292 # This script manages in such a way that all Emacs LISP files to
293 # be compiled are made visible between themselves, in the event
294 # they require or load-library one another.
295 305
296 test $# -gt 0 || return 1 306 test $# -gt 0 || return 1
297 307
298 if test -z "${EMACS}" || test "${EMACS}" = "t"; then 308 if test -z "${EMACS}" || test "${EMACS}" = "t"; then
299 # Value of "t" means we are running in a shell under Emacs. 309 # Value of "t" means we are running in a shell under Emacs.
302 fi 312 fi
303 einfo "Compiling GNU Emacs Elisp files ..." 313 einfo "Compiling GNU Emacs Elisp files ..."
304 314
305 tempdir=elc.$$ 315 tempdir=elc.$$
306 mkdir ${tempdir} 316 mkdir ${tempdir}
307 cp $* ${tempdir} 317 cp "$@" ${tempdir}
308 pushd ${tempdir} 318 pushd ${tempdir}
309 319
310 echo "(add-to-list 'load-path \"../\")" > script 320 echo "(add-to-list 'load-path \"../\")" > script
311 ${EMACS} -batch -q --no-site-file --no-init-file -l script \ 321 ${EMACS_BATCH_CLEAN} -l script -f batch-byte-compile *.el
312 -f batch-byte-compile *.el
313 local status=$? 322 local ret=$?
314 mv *.elc .. 323 mv *.elc ..
315 324
316 popd 325 popd
317 rm -fr ${tempdir} 326 rm -fr ${tempdir}
318 return ${status} 327 return ${ret}
319} 328}

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20